A little help with pexpect

Hussein B hubaghdadi at gmail.com
Sun Jul 19 07:22:57 EDT 2009


Hey,
I'm trying to execute a command over a remore server using pexpect
+++++++++++++++++
url = 'ssh internalserver'
res = pexpect.spawn(url)
print '1'
res.expect('.*ssword:')
print '2'
res.sendline('mypasswd')
print '3'
res.sendline('ls -aslh')
+++++++++++++++++
What I want to do is to send a couple of commands and get the
response.
How to do this?
Thanks.



More information about the Python-list mailing list