On Jun 29, 4:45 am, Dan Stromberg <[EMAIL PROTECTED]> 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 ? > > > [EMAIL PROTECTED]:~# cat ssh2.py > > import pexpect > > import sys > > > child = pexpect.spawn("ssh [EMAIL PROTECTED]") #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('[EMAIL PROTECTED]: ~') print child.before > > > child.sendline('ls -l') > > child.expect('[EMAIL PROTECTED]:') > > print child.before > > > child.sendline('su') > > child.expect('assword:') > > child.sendline('123') > > child.expect('[EMAIL PROTECTED]: /srv/www/gert') print child.before > > > child.sendline('ls -l') > > child.expect('[EMAIL PROTECTED]:') > > 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. -- http://mail.python.org/mailman/listinfo/python-list