Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我使用 Paramiko 从远程 Linux 机器启动一个 shell 脚本。启动 shell 脚本并执行命令make -j8。但是在exec_command制作完成之前返回。
make -j8
exec_command
如果我在本地机器上启动脚本,它会正确执行。
有人可以向我解释这种行为吗?
您需要等待应用程序完成, exec_command 不是阻塞调用。
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"