grover mitchell wrote:
> Hi,
> 
> I am trying to use system to run a command on a remote machine.
> 
> system "ssh", $remote_host[0], "sudo", "-u", "nobody",
> "/usr/bin/remote_command", "--arg1", $arg1, "--arg2", $arg2;
> 
> The problem I run into is that perl will ssh into the remote host and
> give me a shell there, instead of running the remote command on the
> remote system. When I exit, perl will then try and run the remote
> command on my local host. Is there an easy way to accomplish this task
> using system?
> 
> Thanks for any help.
> 

I haven't tested, but there haven't been any other responders yet so I
thought I would chime in.

Have you tried the one argument form of C<system>? There is the
potential for the above to be getting screwed up by the 'exec' rather
than the 'execvp' mentioned in,

perldoc -f system

I suppose. Try joining all of your arguments along with the command into
a single string passed to system and see if that helps. Of course you
could always try Net::SSH::Perl as a substitute.

You also ought to consider using a full path to ssh, and I assume the
above is just a snippet of a larger set of code that does proper error
checking/handling per the C<system> docs ;-)...

HTH,

http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to