pexpect ssh login and ls | grep

crybaby joemystery123 at gmail.com
Mon Dec 31 21:46:24 EST 2007


1) what are these characters:
\x1b]0;
~\x07\x1b[?1034h

in line '\x1b]0;my at mycomp2:~\x07\x1b[?1034h[my at mycomp2 ~]'?

2) Also, how come I don't get 0 or 2(excuting ls command exit code)
from result.split('\r\n')[0] or result.split('\r\n')[1] ?

This is what I get:
>>> import pexpect
>>> child=pexpect.spawn('ssh my at mycomp2')
>>> child.sendline("ls mytest.log > /dev/null 2>&1; echo $?")
41
>>> child.before
>>> print child.before
None
>>> print child.after
None
>>> child.expect([pexpect.TIMEOUT, '\$ '])
1
>>> result=child.before
>>> print result.split('\r\n')[1]
[my at mycomp2 ~]
>>> print result.split('\r\n')[0]
Last login: Mon Dec 31 20:52:09 2007 from com1
>>> print result.split('\r\n')
['Last login: Mon Dec 31 20:52:09 2007 from com1\r',
'\x1b]0;my at mycomp2:~\x07\x1b[?1034h[my at mycomp2 ~]']




More information about the Python-list mailing list