[Tutor] RSH?

Shantanoo Mahajan shantanoo at gmail.com
Thu Nov 3 21:07:59 CET 2005


+++ Bernard Lebel [03-11-05 14:16 -0500]:
| I use plink
| http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html
| 
| Basically you send a system command (os.system) to the plink
| executable. The actuall command will take this form:
| 
| os.system( 'plink -pw %s -ssh %s@%s %s' % ( password, user, hostIP, command ) )
| 
| 
| Now, if you want to run a python script on the remote machine, you
| will have to send two commands (afaik). The first one to cd to the
| python script file, the second to send the python execution command:
| 
| os.system( 'plink -pw %s -ssh %s@%s %s' % ( password, user, hostIP,
| 'cd /blah/blah/' ) )
| os.system( 'plink -pw %s -ssh %s@%s %s' % ( password, user, hostIP,
| 'python scriptname.py' ) )

How about:
os.system( 'plink -pw %s -ssh %s@%s %s' % ( password, user, hostIP, '/absolute/path/of/python /absolute/path/of/python/script' ) )

Also dirty method:

(i,o,e) = os.popen3('telnet hostIP)

Where,
i = input
o = output
e = error

i.write('...') for sending input.
o.readline() and e.readline() for reading data.

Shantanoo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://mail.python.org/pipermail/tutor/attachments/20051104/c36ccffa/attachment.pgp


More information about the Tutor mailing list