Python 为什么stdout.channel.recv_exit_status的返回值为';7';而不是';0';
下面是我从paramiko shell包中使用的python代码,返回值r是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():
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())
。