Arunko Arunko - 1 year ago 66
Bash Question

Access remote machine's exported variable via ssh

So, what I am trying is this:

  • In
    machine, I had set
    export name=arun
    file of

  • Then is executed
    source .bash_profile

  • From
    machine, I am trying
    ssh www@ "echo $name"

This is giving me blank. Is this not supposed to return me

Answer Source

No. You need to escape the variable to be evaluated on the remote shell, not in your local:

ssh www@ ". .bash_profile;echo \$name"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download