我一直在努力从cat命令获取输出
stdin,stdout,stderr = ssh.exec_command("'cat /finusers3/bway/download/input2.dat|wc -l'", False)
for line in iter(stdout.readline, ""):
print(line)
任何帮助将不胜感激。
答案 0 :(得分:-1)
我认为子流程是你需要的:
from subprocess import Popen
from subprocess import PIPE
cmd = 'ls -la'.split()
popen_cmd = Popen(cmd, stdout=PIPE)
output = popen_cmd.communicate()[0]