python - subprocess.Popen() read a file -
i'm trying use subprocess read file stored in remote server.
import subprocess import sys ssh = subprocess.popen(['ssh', 'hjh:passwd@myserver', 'cat', 'data/test.txt'], shell=false, stdout=subprocess.pipe, stderr=subprocess.pipe) result = ssh.stdout.readlines() if result == []: error = ssh.stderr.readlines() print >>sys.stderr, "error: %s" % error else: print result now running results in error
traceback (most recent call last): file "c:/users/hjh/desktop/try.py", line 15, in <module> stderr=subprocess.pipe) file "c:\python27\lib\subprocess.py", line 710, in __init__ errread, errwrite) file "c:\python27\lib\subprocess.py", line 958, in _execute_child startupinfo) windowserror: [error 2] system cannot find file specified does error mean file on server cannot found? or there error in subprocess? google wasn't of me on error.
i work proxy not specified here, can problem?
cheers,
i suppose windows unable find ssh executable. check happens when type ssh in cmd.exe. try adding full path ssh client executable in popen call or add ssh's directory path environment variable.
Comments
Post a Comment