Reputation: 575
I have a script that, in a specific case is required to run a very time-consuming script on a remote computer. I currently do this with:
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'\'')
Now - so far so good.. How could I wait for python /home/username/flamethrower.py
in the script that initially started it and possibly have a minimalistic feedback?
The computer running the script that starts flamethrower.py
on the remote computer is a windows 8.1, the computer where flamethrower.py
is run, is a Debian wheezy.
pseudo coded:
[...] # 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)
Upvotes: 0
Views: 169
Reputation: 28405
Have your remote script output to some log file, including when finished, then poll the remote connection every so often for the finish output, (and fetch the remaining output).
Upvotes: 2