Results 1 to 2 of 2
Hi,
I have scripted this code to ssh into my remote server and log back some info.
import sys, os, re, optparse, traceback, types, time, getpass
import pexpect, pxssh
import ...
- 11-03-2010 #1Just Joined!
- Join Date
- Jun 2008
- Posts
- 58
ssh script
Hi,
I have scripted this code to ssh into my remote server and log back some info.
However each time I get 0byte files logged.import sys, os, re, optparse, traceback, types, time, getpass
import pexpect, pxssh
import readline, atexit
begin = time.time()
os.system('nc -l 2222 > log%s &' %begin)
time.sleep(50)
child = pexpect.spawn ('ssh david@192.168.0.14')
child.expect ('password:')
child.sendline ('mypass')
child.expect ('$')
child.sendline ('df |nc 192.168.0.14 2222')
child.sendline ('exit')
child.sendline ('exit')
eg
No when I do the same stuff manually:0 Nov 3 11:15 log1288782916.15
local machine
Then ssh into remote server & donc -l 2222 > log &
it worksdf |nc 192.168.0.14 2222
I do a strace on nc ( launched from script )2880 Nov 3 11:27 log
Any thoughts guys?shutdown(4, 0 /* receive */) = -1 ENOTCONN (Transport endpoint is not connected)
Thanks in advance
David
- 11-03-2010 #2Just Joined!
- Join Date
- Jun 2008
- Posts
- 58
oopss, theres a typo.
child.sendline ('df |nc 192.168.0.18 2222').
Back to my client machine


Reply With Quote