Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Re: First Unix Admin Script - Request for Constructive Critisism

by D.Millin (Beadle)
on Feb 08, 2003 at 23:37 UTC ( #233793=note: print w/replies, xml ) Need Help??


in reply to Re: First Unix Admin Script - Request for Constructive Critisism
in thread First Unix Admin Script - Request for Constructive Critisism

Hi tachyon,

I have been given some thought to your suggestion to have a check_call sub. I guess one approach would be to adapt check_call each type, or class of command. Reporting would still need to be done in plain english for the operators, so instead of passing @stuff, I could always pass in appropriate parameters. BTW, is there any way of redirecting STDOUT,STDERR when system is called in a list context?


Darren
  • Comment on Re: Re: First Unix Admin Script - Request for Constructive Critisism

Replies are listed 'Best First'.
Re^3: First Unix Admin Script - Request for Constructive Critisism
by tall_man (Parson) on Feb 09, 2003 at 01:08 UTC
    You ask about redirecting STDOUT and STDERR for system calls given as lists. A good way to do this is with the module IPC::Run.
    use IPC::Run qw( run ) ; run \@cmd, \$in, \$out, \$err;

    One idea you might be able to use for parameterizing your error messages for various commands would be to pass in a hash reference containing explanatory messages indexed by return codes. Also see perlvar for how you can use the variable $! to obtain error message strings after a failed system call.

    Finally, the reason spelled-out file handles are considered "bad style" compared to IO::File is that they create global names, which might conflict with other modules. IO::File uses unique private symbols instead.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2023-12-07 06:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (32 votes). Check out past polls.

    Notices?