pxssh submit su commands = very very slow
gert
gert.cuykens at gmail.com
Sat Jun 28 22:08:59 EDT 2008
this does the same except 100 times faster ?
I don't understand the logic about the prompt, its not the same as the
output from the bash shell ?
root at r12276:~# cat ssh2.py
import pexpect
import sys
child = pexpect.spawn("ssh gert at 127.0.0.1")
#child.logfile = sys.stdout
i = child.expect(['assword:', r'yes/no'],timeout=120)
if i==0:
child.sendline('123')
elif i==1:
child.sendline('yes')
child.expect('assword:', timeout=120)
child.sendline('123')
child.expect('gert at rxxxx.ovh.net: ~')
print child.before
child.sendline('ls -l')
child.expect('gert at rxxxx.ovh.net:')
print child.before
child.sendline('su')
child.expect('assword:')
child.sendline('123')
child.expect('gert at rxxxx.ovh.net: /srv/www/gert')
print child.before
child.sendline('ls -l')
child.expect('root at rxxxx.ovh.net:')
print child.before
More information about the Python-list
mailing list