in reply to stop process based on exit status.
You'll probably want to take a closer look at the IPC::Run docs for more details on what all it can do. It also offers fairly flexible control over interactive programs if you want to do that in the future. I tend to use it over open or system any time I need to start doing anything more than just run the program.#!/usr/bin/perl use strict; use warnings; use IPC::Run qw( start pump finish ); open(LOG, '>', 'log') or die "Unable to open log: $!"; my ($in, $out); my $h = start([ 'run_tool', '-f', 'test.tcl' ], \$in, \$out, \$out); while($h->pump) { print LOG $out; $out = ''; } $h->finish; close(LOG); print "Exit code was: " . $h->result . "\n";
|
---|