I am trying to add the results of ls/home into mylogfile.txt through ssh. If I run the script there is no error but there is no output in mylogfile.txt.
#!/usr/bin/env python
import pexpect
import sys
child=pexpect.spawn('ssh anony@192.168.42.2')
fout=file('mylogfile.txt','w')
child.logfile=fout
child.expect("password:")
child.sendline("xxxxx")
child.expect('$')
child.sendline('ls /home')
anony:pythontest/ $ cat mylogfile.txt
anony@192.168.42.2's password: xxxxxxx
ls /home
Why's there only tow commands in mylogfile.txt?