【发布时间】:2015-01-26 02:31:52
【问题描述】:
我正在尝试使用子进程来读取存储在远程服务器中的文件。
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
现在运行这会导致错误
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] The system cannot find the file specified
这个错误是否意味着找不到服务器上的文件?还是子流程有错误? Google 在这个错误上对我帮助不大。
我还使用此处未指定的代理,这可能是个问题吗?
干杯,
【问题讨论】:
标签: python ssh proxy subprocess