develooper Front page | perl.modules | Postings from June 2006

Module submission IPC::System::Simple

Thread Next
Perl Authors Upload Server
June 27, 2006 19:58
Module submission IPC::System::Simple
Message ID:

The following module was proposed for inclusion in the Module List:

  modid:       IPC::System::Simple
  DSLIP:       idpfp
  description: system() made simple
  userid:      PJF (Paul Jamieson Fenwick)
  chapterid:   5 (Networking_Devices_IPC)



    The following was posted to on 25th June, and is
    my original motivation for the module. I'm not sure if it was caught
    by any filters or moderation on the way in, so I'm reproducing it

    ---cut here---

    Greetings, my module overlords,

    I'm currently in the process of preparing course materials on using
    Perl for system administration, and I've hit a snag. I can't find
    *any* way to make system() as simple and easy as I would like for
    the most simple and common cases. The full discussion can be found
    on PerlMonks[1], but in short my ideal module would look like this:

    use Some::Module qw(run);

    # Run some command. Throw an exception on core-dump, #
    signal-death, or non-zero exit value. This calls # single-argument
    system underneath.


    # Run some command as above, but use multi-argument # system.


    # Run some command, but allow an exit-status of 0..2 # to be
    non-fatal. Returns the exit value. my $exit_value = run([0..2],

    The intent is to make it both simple and easy to "do the right
    thing" in terms of error-checking for the most simple cases when
    using system(). I'm not looking for fancy pipes or process control,
    but I am looking for something that will give excellent diagnostics
    (and exceptions) when things go wrong.

    This is about making "simple things easy"; we already have lots of
    modules that make hard things possible. I feel such a module would
    have great use with system administrators, who often know enough
    Perl to call system(), but not enough to properly check (and unpack)
    $? and $! .

    Unfortunately, I can't find any such module. IPC::Run3 comes close,
    but looking over the source code it doesn't appear to check for
    signals, core-dumps, or give an easy way to get to the error-status.
    IPC::Run fails the simplicity test, and Perl6::Builtins requires the
    developer to actually check their return values. IPC::Cmd is
    actually very close, but doesn't do the diagnostics that I'm after.

    As such, I'm intending to write a module to fulfill these
    requirements, and hence I need a module name, or convincing that I
    really am reinventing yet another wheel. My current choice of names
    is "IPC::System::Simple", which I believe both fits into the
    existing namespace tree, and makes it reasonably clear about what it
    does. I'd actually love to call it "System::Simple", but I feel that
    doesn't follow namespace conventions, although I'd like to be
    convinced otherwise.

    Any advice, discussion, criticism, or questions would be

    Many thanks!



    ---cut here---

    As it happened, in response to my discussion on PerlMonks Steve
    Fink produced IPC::Run::Simple, which implements a related idea.
    Steve's module doesn't throw exceptions by default, and requires
    much longer arguments to check return values. As such,
    IPC::Run::Simple doesn't actually meet my goal of making it as
    simple as possible to complete the task at hand.

    The discussion on IPC::Run::Simple versus what I'm tentatively
    calling IPC::System::Simple is continuing on PerlMonks, and it
    appears that Steve and I actually have different design goals. I
    feel that throwing exceptions is the Right Thing to do on failure,
    as well as having the easiest-possible path forward should a
    developer wish to insist on a command's exit status.

    Reading the thread on Perlmonks should help explain things further.
    However I would very much appreciate any feedback, comments, ideas,
    or discussion that you may have.

    Many thanks,


  enteredby:   PJF (Paul Jamieson Fenwick)
  enteredon:   Wed Jun 28 02:58:15 2006 GMT

The resulting entry would be:

::Simple          idpfp system() made simple                         PJF

Thanks for registering,

PS: The following links are only valid for module list maintainers:

Registration form with editing capabilities:
Immediate (one click) registration:

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About