pexpect ssh login and ls | grep
- From: crybaby <joemystery123@xxxxxxxxx>
- Date: Mon, 31 Dec 2007 11:40:12 -0800 (PST)
I need to ssh into a remote machine and check if mytest.log file is
there. I have setup ssh keys to handle login authentications.
How do I determine if mytest.log is there by using Pexpect. What I
have done so far is spawned a child for ssh.
1) Now what do I do to execute shell_cmd(ls and grep), spawn another
child?
2) Can I use the same child that was spawned for ssh, if so how?
3) After executing the ls -l|grep mystest.log, how do I get the value
from pexpect?
shell_cmd = 'ls -l | grep mytest.log'
child = pexpect.spawn ('ssh my@mycomp2')
#child.sendline(shell_cmd)
3child.sendline("ls")
:~[print child.before
'my@mycomp2 'child.after
Traceback (most recent call last):child.sendline('/bin/bash', ['-c',shell_cmd])
File "<stdin>", line 1, in ?
TypeError: sendline() takes at most 2 arguments (3 given)
thanks,
joe
.
- Prev by Date: Re: Newbie: Why doesn't this work
- Next by Date: Re: Bizarre behavior with mutable default arguments
- Previous by thread: What's the limit of variables size in pyhton?
- Index(es):
Relevant Pages
|