Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
Do you mean it is exported in your local .bashrc or the one on the server you are connecting to? –  terdon Jul 30 '13 at 14:55
    
@terdon on the server I'm connecting to –  sean hawk Jul 30 '13 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 '13 at 15:03
    
@terdon sorry another typo :) –  sean hawk Jul 30 '13 at 15:45

1 Answer 1

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'
share|improve this answer
    
question updated, thanks! –  sean hawk Jul 29 '13 at 14:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.