Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 为什么stdout.channel.recv_exit_status的返回值为';7';而不是';0';_Python_Python 2.7_Ssh_Paramiko - Fatal编程技术网

Python 为什么stdout.channel.recv_exit_status的返回值为';7';而不是';0';

Python 为什么stdout.channel.recv_exit_status的返回值为';7';而不是';0';,python,python-2.7,ssh,paramiko,Python,Python 2.7,Ssh,Paramiko,下面是我从paramiko shell包中使用的python代码,返回值r是7,而不是0。但是,如果我在远程shell中运行相同的命令,并且echo$?,它将返回0 cmd = "curl --fail -s \"http://localhost:%s/\" > /dev/null" %HTTP_PORT stdin, stdout, stderr = ssh.exec_command(cmd) while not stdout.channel.exit_status_ready():

下面是我从paramiko shell包中使用的python代码,返回值r是
7
,而不是
0
。但是,如果我在远程shell中运行相同的命令,并且
echo$?
,它将返回
0

cmd = "curl --fail -s \"http://localhost:%s/\" > /dev/null" %HTTP_PORT
stdin, stdout, stderr = ssh.exec_command(cmd)
while not stdout.channel.exit_status_ready():
    r = stdout.channel.recv_exit_status()
print "r is is %d" %(r)    #it returns '7'

问题是web服务器在这段时间内没有完全启动。

检查
stdout
stderr
中的内容。我无法复制。我尝试了相同的命令集,但得到了
0
。你能:1。从命令2中删除
--fail-s
>/dev/null
。打印
stdout
stderr
?@whjm,stdin和stderr都给出与stdout相同的结果,都返回'7'@hansaplast,都返回7Remove
--fail-s
打印'stdout:%s,stderr:%s'(stdout.read(),stderr.read())