When I run my program interactively, it works fine:
ssh somehost
$ ~/some/path/somescript.py
When I run my program over ssh directly, it doesn't work. The variable PYTHONPATH
is not set, because .bashrc
is not sourced.
ssh somehost ~/some/path/somescript.py
If I run ssh somehost 'source ~/.bashrc; ~/some/path/somescript.py'
, it works fine.
But the latter wouldn't work for some other folks, e.g. using tcsh and not having a ~/.bashrc
at all).
What is the command to run a thing via ssh on another host that works for all shells?
bash
, then it sources.bash_profile
or.profile
for an interactive login, and.bashrc
for a non-interactive login. If your login shell is bash invoked assh
or ash or ksh, it sources.profile
for an interactive login and nothing for a non-interactive login. – Gilles 'SO- stop being evil' Jun 18 '11 at 07:45