Possible Duplicate:
dot file not sourced when running a command via ssh
This is a continuation of prev. my question dot file not sourced when running a command via ssh (I could not add enough information at the orig. post as it only allows 600 characters. Sorry if I did it wrong).
In a nut shell: if I have bash as the default shell on host1 and on host2, and
if I run from host1 the following:
ssh host2 ~/some/path/somescript.py it doesn't work.
This is because none of the .-files are sourced on the remote host so my PYTHONPATH is not set and =the command fails.
This brings us to a shorter version of the problem:
There is no . file that is sourced when I run bash on a remote host (i.e. non-interactively).
To prove this, I created on the remote host the following files:
- .bash_login
- .bash_profile
- .bashrc
- .profile
and added as a 1st line an echo command to each of them, namely:
- to .bash_login : echo "hi from .bash_login"
- to .bash_profile : echo "hi from .bash_profile"
- to .bashrc : echo "hi from .bashrc"
- to .profile : echo "hi from .profile"
However if I run say
ssh name@host2 "ls ~/foo" I only see an output of "ls" but no echo output.
And why indeed it would echo? The man actually says:
When bash is started non-interactively, to run a shell script, for example, it looks > for the variable BASH_ENV in the environment, expands its value if it appears there, and uses the expanded value as the name of a file to read and execute. Bash behaves as if > the following command were executed: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi but the value of the PATH variable is not used to search f
In other words, seems that according to the manual when bash is started non-interactively there is NO .-file that it runs by default.
One has to set it in an env. var-le "BASH_ENV" if she wants to source a file.
But then this seems to be an impossible thing to accomplish as... where one can set BASH_ENV or anything else as there is no file that is sourced?!?!?!?
This seems crazy. Am I the only man on Earth who needs to run bash non-interactively on a remote machine via ssh?
Please help. Thanks in advance.