0

I'm sort of confused of login shells and interactive shells.

If I run

ssh my_remote_server 'echo $HOME'

I can get

/home/shawk

But when I run

ssh my_remote_server 'echo $ANOTHER_VAR'

I got a blank line.

export ANOTHER_VAR=$HOME/tr is set in both ~/.bashrc and ~/.profile on my_remote_server. So the question is, where should I set this variable? my_remote_server runs Ubuntu 12.04 btw.

4
  • Do you mean it is exported in your local .bashrc or the one on the server you are connecting to?
    – terdon
    Jul 30, 2013 at 14:55
  • @terdon on the server I'm connecting to
    – sean hawk
    Jul 30, 2013 at 14:57
  • Hang on, are you setting it with the dollar sign? I mean do you have $ANOTHER_VAR=$HOME/tr in your .bashrc or ANOTHER_VAR=$HOME/tr?
    – terdon
    Jul 30, 2013 at 15:03
  • @terdon sorry another typo :)
    – sean hawk
    Jul 30, 2013 at 15:45

1 Answer 1

2

Note that variables are expanded in double quotes by the shell. It means the local value of the variable is printed. To get the remote variable, you have to use single quotes or backslash the dollar sign:

ssh remote_server 'echo $ANOTHER_VAR'
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .