Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: IPC::System::Simple: Why isn't my exception caught?

by ikegami (Pope)
on Nov 20, 2013 at 17:36 UTC ( #1063563=note: print w/ replies, xml ) Need Help??


in reply to IPC::System::Simple: Why isn't my exception caught?

capture('bash', '-o', 'pipefail', '-c', 'cat "$1" | wc -l', 'dummy', $file)

This also solves your problem with file names with spaces or other shell metachars.

This is just an example, right? Cause you could use the following or a small amount of Perl code.

capture('wc', '-l', $file)


Comment on Re: IPC::System::Simple: Why isn't my exception caught?
Select or Download Code
Re^2: IPC::System::Simple: Why isn't my exception caught?
by karlgoethebier (Curate) on Nov 20, 2013 at 20:24 UTC

    Your advice looks a bit like hermetism to me - for the moment ;-)

    So i need just a moment to think about/try it.

    But BTW, here is what i figured out in a hurry using IPC::Run as advised by kschwab:

    #!/usr/bin/env perl + use IPC::Run qw( start finish ); use strict; use warnings; my @cat = qw( cat foo ); my @wc = qw( wc -l); my $h = start \@cat, '|', \@wc, '2>', '/dev/null'; $h->finish; print $h->full_result(0) . qq(\n); print $h->full_result(1) . qq(\n); __END__ karls-mac-mini:Desktop karl$ ./ipc.pl + 0 + 1 + 0

    Looks good/like expected. Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (13)
As of 2014-10-24 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (132 votes), past polls