Python 如何等待在脚本中使用ssh在远程计算机上启动的进程?
我有一个脚本,在特定情况下,需要在远程计算机上运行非常耗时的脚本。我目前是通过以下方式完成这项工作的:Python 如何等待在脚本中使用ssh在远程计算机上启动的进程?,python,ssh,cross-platform,paramiko,Python,Ssh,Cross Platform,Paramiko,我有一个脚本,在特定情况下,需要在远程计算机上运行非常耗时的脚本。我目前是通过以下方式完成这项工作的: if specific_case: client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect('10.0.0.1', username='username', password='password') stdi
if specific_case:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('10.0.0.1', username='username', password='password')
stdin, stdout, stderr = client.exec_command('tmux new-session -d -s session_name \'python /home/username/flamethrower.py'\'')
现在-到目前为止还不错。。我怎么能在最初启动它的脚本中等待python/home/username/flamethrower.py
,并且可能有一个最低限度的反馈
在远程计算机上运行启动FlameSprower.py
脚本的计算机是windows 8.1,运行FlameSprower.py
的计算机是Debian哮喘病
伪编码:
[...] # as above
while not stdin, stdout, stderr = client.exec_command('tmux new-session -d -s session_name \'python /home/username/flamethrower.py'\''):
#while it's not done, print a dot every minute
sys.stdout.print('.')
sys.flush()
sleep(60)
将远程脚本输出到某个日志文件,包括完成时,然后每隔一段时间轮询远程连接以获得完成输出(并获取剩余输出)。这也是我的想法,非常感谢您的建议!