Dave Thomas <Dave / PragmaticProgrammer.com> wrote:
>
>Robert Feldt <feldt / ce.chalmers.se> writes:
>
> > Is there some way of preventing the "command not found" printed by Ruby
> > when the command specified in backquotes isn't found? The example in the
> > book (p. 75) shows how to get an exception back when this happens but it
> > doesn't avoid printing the "command not found" message to stderr.
>
>You could look at using open3, which lets you capture the stderr of a
>subprocess. The downside is that open3 hides the return status of the
>subprocess from you ($? is always 0).

It also produces zombies if you don't reap your children.  But
use the variations on wait to reap children and you can kill two
birds with one stone.

It is conceptually more complex, but I have used exactly that
approach in Perl quite successfully for tasks like having a
sub-process that is quiet unless its return is true in which
case I spit out its STDERR, and for running a long list of
commands with several in parallel.  I posted the latter:

http://www.perlmonks.org/index.pl?node_id=28870

Cheers,
Ben
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com