paramiko SSH exec_command(shell script) returns before completion

天涯浪子 提交于 2019-11-29 00:33:52

问题


I launch a shell script from a remote Linux machine using paramiko. The shell script is launched and execute a command make -j8. However the exec_command returns before the completion of the make.

If I launch the script on the local machine it executes correctly.

Could someone explain me this behaviour ?


回答1:


You need to wait for application to finish, exec_command isn't a blocking call.

print now(), "before call"
stdin, stdout, sterr = ssh.exec_command("sleep(10)")
print now(), "after call"
channel = stdout.channel
print now(), "before status"
status = channel.recv_exit_status()
print now(), "after status"


来源:https://stackoverflow.com/questions/3215727/paramiko-ssh-exec-commandshell-script-returns-before-completion

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!