go ahead... be a heretic | |
PerlMonks |
Re: Show Unix Talk?by hacker (Priest) |
on Oct 25, 2002 at 11:58 UTC ( [id://207967]=note: print w/replies, xml ) | Need Help?? |
Or, you could do it in a more proper fashion by using IPC::Open3 and capture the success or failure of that command you're executing in the shell. `backticks` are something you should never EVER use, ever. If you insist on using them, ALWAYS make sure to use the /full/path/to/binary in the `call` you use. You could also use "system()-in-list-mode" to try to get what you want, and make sure to wrap your calls in something that can return success or failure. Alternately, you can do something like:
You may have to set up your own signal handler to capture SIGPIPE and others. If you use `backticks` to execute this command, $? will not be set to what you expect (check perlvar for more details on what $? means). perlfaq8 also has a section on this exact topic. Give it a read, it may prove enlightening. While I agree with sauoq about NOT turning your web browser into a remote shell, his suggestion of using `backticks` for this is slightly incorrect, given your request (though I see his sarcasm in suggesting it). Backticks will execute a system command and return what was sent to STDOUT by that command. You only want to test the success or failure of that system command, two very different things. Good luck!
In Section
Seekers of Perl Wisdom
|
|