Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

Re: shell execution question

by kelan (Deacon)
on Jun 07, 2003 at 03:36 UTC ( #263911=note: print w/replies, xml ) Need Help??

in reply to shell execution question

You probably want to be using the system command instead of using backticks. Backticks capture the output of the command and return it to the Perl program. The system command, however, goes off and executes the program, returning the exit value to the Perl program. That seems to be what you want for the if condition, where you're checking for a return value of 0 (successful exit). For the ssh command inside the if block, maybe take a look at the exec command. It starts the given command, replacing the running Perl program, which it kind of looks like you want to do. Maybe give us a better idea of what the intended operation of your program is and we can help a bit more.


Perl6 Grammar Student

Replies are listed 'Best First'.
Re: shell execution question
by hacker (Priest) on Jun 07, 2003 at 12:18 UTC
    I've always been a fan of IPC::Open3 for things like this. With it, you can catch and manipulate STDIN, STDOUT, and STDERR, and it makes things like ping, ssh, rsync and rlogin type-tasks very easy.

    You could also look into Net::Ping, Net::SSH, File::Rsync, and File::Remote, depending on exactly what it is you're trying to do on that remote system.

    `Backticks` are almost never what you want to use, the most-obvious reason being the glaring security implications.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://263911]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2022-12-08 02:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found