I don't get 0 or 2(excuting ls command exit code)
from result.split('\r\n')[0] or result.split('\r\n')[1].  I have to
try another method.

Regular shell ssh login:

[EMAIL PROTECTED] ~]$ ssh [EMAIL PROTECTED]
Last login: Mon Dec 31 20:51:09 2007 from com1
[EMAIL PROTECTED] ~]$

Pexpect Login:
>>> import pexpect
>>> child=pexpect.spawn("ssh [EMAIL PROTECTED]")
>>> child.sendline("ls mytest.log > /dev/null 2>&1; echo $? ")
42
>>> child.expect([pexpect.TIMEOUT, r"\$"])
1
>>> result1=child.before
>>> result2=child.after
>>> print result1
Last login: Tue Jan  1 11:22:05 2008 from com1
[EMAIL PROTECTED] ~]
>>> print result2
$
>>> print result1.split('\r\n')[1]
[EMAIL PROTECTED] ~]
>>> print result1.split('\r\n')[0]
Last login: Tue Jan  1 11:22:05 2008 from com1

thanks.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to