Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: trapping system error

by thargas (Deacon)
on Aug 31, 2010 at 13:19 UTC ( [id://858166]=note: print w/replies, xml ) Need Help??


in reply to Re: trapping system error
in thread trapping system error

The answer is almost always: don't use system. If your question is using mkdir as an example, then the answer is use backticks like:
my $output = `mkdir -p /what/ever 2>&1`;

If the command to be run will produce output on stdout as well as errors on stderr, then you'll be better off using one of the modules which will allow you to run a command and receive stderr and stdout separately, like IPC::Run, ...

If you really meant mkdir specifically, why not use perl's mkdir, or File::Path's mkpath? You won't have to do any error-trapping; you can just ask perl what happened.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (7)
As of 2024-04-19 09:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found