Reputation: 25
Python subprocess.popen is easy as pie on local machine, but is it possible to call it over a network?
Example, say I have 3 PCs, one is called workstation-pc, the others are called node1-pc and node2-pc...
Is it possible to call a process on, say, node1-pc, from workstation-pc, preferably without having to run special server software on node1-pc?
In any case, many thanks for any response!
Gilles
EDIT Forgot to mention that I am using Python 3
Upvotes: 0
Views: 1035
Reputation: 19040
I would recommend the use of either:
Example with Fabric:
from fabric.api import env, run
env.hosts = ['host1', 'host2']
def mytask():
run('ls /var/www')
Upvotes: 1
Reputation: 87084
Fabric is probably the way to go, however, there is nothing to stop you executing remote commands via ssh
in *nix environments.
import subprocess
p = subprocess.Popen(['ssh', 'node1-pc', 'ls', '-ltr', '/etc'], stdout=subprocess.PIPE)
out, err = p.communicate()
out
will contain the stdout of the remote process.
Upvotes: 0