perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nguyen Vu Hung <vu-h...@cnt.mxt.nes.nec.co.jp>
Subject IPC::Run question
Date Mon, 20 Aug 2007 06:59:04 GMT
After sending a hardtime with IPC::Run, I still didn't understand it
from usage example, so I post it here.

In the code below, what are@cmd, $in, $out, $err? How to declare them?

Question 01:

#http://www.annocpan.org/~RSOD/IPC-Run-0.80/lib/IPC/Run.pm

   ## Using run() instead of system():
      use IPC::Run qw( run timeout ) ;

      run \@cmd, \$in, \$out, \$err, timeout( 10 ) or die "cat: $?"

      # Can do I/O to sub refs and filenames, too:
      run \@cmd, '<', "in.txt", \&out, \&err or die "cat: $?"
      run \@cat, '<', "in.txt", '>>', "out.txt", '2>>', "err.txt" ;

      # Redirecting using psuedo-terminals instad of pipes.
      run \@cat, '<pty<', \$in,  '>pty>', \$out_and_err ;


Question 02:

The following code using IPC::open3 ( works fine under Perl 5.5.6,
mod_perl 1.3, Apache 1.3.x ) to run and command.
How does it look like if I port it to IPC::Run ( under Perl 5.5.8,
mod_perl 2.0.3, Apache 2.0.52 )
# IPC::open3 is no longer available under the new environment.

my $OUT = new FileHandle;
my $IN = new FileHandle;
my $ERR = new FileHandle;

my $tie_stdin = tied *STDIN;
my $tie_stdout = tied *STDOUT;
my $tie_done = undef;
untie *STDIN if $tie_stdin;
untie *STDOUT if $tie_stdout;
my $pid;

#eval { $pid = open3( $OUT, $IN, $ERR, "/path/to/cmd $paramx" ) };

Mime
View raw message