Using python in windows to run a remote perl script on linux -
i need connect windows machine remote linux server , execute perl script. i've tried using
command = "perl /usr/local/xfer/file.pl -ssh root@"+hostname+" -pw password -batch" pid = subprocess.popen(command, shell=true)
but tells me can't open perl script "usr/local/xfer/file.pl'": no such file or directory.
what doing wrong here, , how can work?
the command above uses perl installation on windows said script located on linux server.
so need wrap invocation in call ssh:
child = subprocess.popen(['plink', '-ssh', 'user@server', 'perl', '/usr/local/xfer/file.pl', '-ssh', 'root@'+hostname, '-pw', 'password', '-batch'], shell=true)
note: never ever use "string command" version of subprocess.popen()
, pass command , arguments list.
back problem: start plink
(command line version of putty since windows doesn't have ssh(1)
) other list elements arguments.
note putty agent must run work, otherwise plink
ask password. see manual details.
Comments
Post a Comment