i'm trying to run a python script from host to some clients via subprocess.popen. The command is sort of fire and forget and the process in the clients should run for an unlimited time untill i kill it. the problem is - when i run this line in python the process run on the clients for an hour and then suddenly stops after 1 hour and 2 minutes :
subprocess.Popen(["rsh {} {} {}".format(ipClient,command,args)], shell=True)
where "command" is the path and the command in the clients.
and when i simply run
rsh 'ip' 'command' 'args'
in the shell it works as expected and does not stop suddenly.
any idea?
While
subprocess.Popen
might work for wrappingssh
access, this is not the preferred way to do so.I recommend using paramiko.
And If you want to simulate a terminal, as if a user was typing:
Example usage:
exec_cmd('pwd')
If you don't know the prompt in advance, you can set it with: