pxssh submit su commands = very very slow
Dan Stromberg
dstromberglists at gmail.com
Sat Jun 28 22:45:26 EDT 2008
On Sat, 28 Jun 2008 19:08:59 -0700, gert wrote:
> 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
You could try changing the prompt (pxssh appears to have a way of doing
that), but I prefer to set up passwordless, passphraseless ssh and do
each command separately. For the rootly portions, you might look into
passwordless sudo if you go that route.
Here's something about setting up passwordless, passphraseless ssh:
http://stromberg.dnsalias.org/~strombrg/ssh-keys.html
More information about the Python-list
mailing list