views:

212

answers:

1

I'm currently writing a script to set some PATH in a remote machine using ssh. I have successfully set the variables in the .bashrc. However, it the last step of my script is "source .bashrc". However, when i ssh to the machine manually, the PATH is still not set. What is the problem?

+1  A: 

If on computer A, you set PATH with a script run via ssh on computer B, in a script, and then log in to computer B again, PATH will go back to what it was initially. The computer doesn't remember the value of PATH between processes, and it doesn't share it. PATH is an environment variable which is specific to each process. If you use

 export PATH

then it will be inherited by child processes, but here your second login session is not a child process of the first one.

Kinopiko
what if i want to set some path by default when i login?
CKeven