Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

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)

Replies are listed 'Best First'.
Re^2: IPC::System::Simple: Why isn't my exception caught?
by karlgoethebier (Monsignor) 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$ ./ + 0 + 1 + 0

    Looks good/like expected. Best regards, Karl

    «The Crux of the Biscuit is the Apostrophe»

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1063563]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (11)
As of 2018-06-19 16:15 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (114 votes). Check out past polls.