When running  shell commands from perl script with an open() instead of
system() or exec how is the return value snagged.

I guess, if it doesn't die, it worked but how to snag that information
and at what point?

------- 8< snip ---------- 8< snip ---------- 8<snip ------- 
#!/usr/local/bin/perl

use strict;
use warnings;

my $log = '/home/harry/some.log';
my $cmd = 'rsnapshot -c rsnap_Home.conf hourly';

open my $fh, '>', "$log" or die
  "Can't open $log: $!";

open my $ch, '-|', "$cmd" or die
  "Can't run $cmd: $!";

while (<$ch>) {
  print;
  print $fh;
}

close $fh;
close $ch;

__END__


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to