pxssh submit su commands = very very slow

gert gert.cuykens at gmail.com
Sun Jun 29 08:49:59 EDT 2008


On Jun 29, 4:45 am, Dan Stromberg <dstrombergli... at gmail.com> wrote:
> 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 g... 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('g... at rxxxx.ovh.net: ~') print child.before
>
> > child.sendline('ls -l')
> > child.expect('g... at rxxxx.ovh.net:')
> > print child.before
>
> > child.sendline('su')
> > child.expect('assword:')
> > child.sendline('123')
> > child.expect('g... at rxxxx.ovh.net: /srv/www/gert') print child.before
>
> > child.sendline('ls -l')
> > child.expect('r... 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

My boss does not allow me to cp a key on the phone server. I only have
a email with some commands and passwords.



More information about the Python-list mailing list