Operating System - HP-UX
1753378 Members
4940 Online
108792 Solutions
New Discussion юеВ

Re: Running python from ssh

 
Tingli
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
Kenan Erdey
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
Mel Burslan
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...
Bill Hassell
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
Dennis Handly
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
Tingli
Esteemed Contributor

Re: Running python from ssh

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