cancel
Showing results for 
Search instead for 
Did you mean: 

Running python from ssh

 
Highlighted
Esteemed Contributor

Running python from ssh

There is a difference between python 2.5.1 and python 2.5.2 in hp-ux 11.23. Python 2.5.1 is installed in /usr/bin while python 2.5.2 is installed in /usr/local/bin.

The issue is that when running 2.5.1 from python, I don't need to put a full path before python but if I run 2.5.2, I had to put the full path /usr/local/bin for python, although I have /usr/local/bin in $PATH.

How does ssh treat the PATH for running a remote command?
5 REPLIES 5
Highlighted
Honored Contributor

Re: Running python from ssh

Hi,

if you type env or echo $PATH, you can see the value of PATH variable in your system. the order of phyton's binary in PATH shows which phyton binary to run. if you want 2.5.2 version to be run it's path must be after than the older.

Kenan.
Computers have lots of memory but no imagination
Highlighted
Honored Contributor

Re: Running python from ssh

If you happen to look at the top section of the file

/opt/ssh/etc/sshd_config

you will see something like

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin

this should tell you what ssh takes as its default path on the server where this sshd is running. Provided that I have not done this myself, but it should be possible to add /usr/local/bin to the path in the source file and compile it for your own use.

Hope this helps
________________________________
UNIX because I majored in cryptology...
Highlighted
Honored Contributor

Re: Running python from ssh

Setting the expected environment on a remote system is always a problem that should be addressed. $PATH on your local machine is meaningless on the remote machine, regardless of whether you are using telnet, ssh, rexec, ftp, etc. Now you can customize sshd on the remote machine, but are there other systems? I tend to write code that is self-contained and that means PATH is part of the included code. Similarly, a self-contained script will run without any assumptions about the user's environment, which is actually a security enhancement and makes the code ready for at, batch and/or cron.


Bill Hassell, sysadmin
Highlighted
Acclaimed Contributor

Re: Running python from ssh

>How does ssh treat the PATH for running a remote command?

Any reason you just don't use the absolute paths for all commands other than /usr/bin?
And if using a script, do what Bill says?

That's what you need to do for remsh, except it does have /usr/local/bin:
/usr/bin:/usr/ccs/bin:/usr/bin/X11:/usr/contrib/bin:/usr/local/bin
Highlighted
Esteemed Contributor

Re: Running python from ssh

I will suggest user uses full path name in his scripts.