Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Complete solution for system commands?

by HuckinFappy (Pilgrim)
on Jul 03, 2006 at 04:58 UTC ( [id://558930]=perlquestion: print w/replies, xml ) Need Help??

HuckinFappy has asked for the wisdom of the Perl Monks concerning the following question:

I must have written 20 different routines in 12 years to run a system command. Most of them are pretty standard, they spawn a command, then analyze both $? and $!, and if $? has a value, analyze it to find what happened. Maybe handles some I/O redirection, using callbacks if we're fancy.

It's just one of the lame things my coworkers and I have to confess to. Despite the sheer number of times we all do this, we've never put it in one central location. Time to fix that mistake

So I'm formalizing something for us. I've looked a little at using IPC::Run as a base, but I'm wondering if anyone has a tutorial for it? It's documentation is extensive, but the module is so vast, i would learn better with good examples

The other questions would be:

  • What is your solution? What is your common code for running a system command
  • Have you used IPC::Run? What was your experience?
  • If you don't use it, is there another good module you've learned to love?

Thanks Brothers!

~Jeff

Replies are listed 'Best First'.
Re: Complete solution for system commands?
by GrandFather (Saint) on Jul 03, 2006 at 05:15 UTC
Re: Complete solution for system commands?
by Moron (Curate) on Jul 03, 2006 at 09:36 UTC
    Even though IPC::Run3 is the most official way, I usually prefer to write a wrapper class around IPC::Open3, so as to provide full control over the pipes and create sufficient flexibility for having one central solution. This depends on the requirements you want to support, but, for example, you might want to fetch just some output into memory and conditionally abort. You might want to process and submit the output from one spawned process before conditionally submitting to a second one and so on. It takes some careful design to be able to cover all the possibilities that may be necessary for a site.

    -M

    Free your mind

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://558930]
Approved by graff
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: (3)
As of 2024-03-29 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found