[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    IPC::Run question
From:       Nguyen Vu Hung <vu-hung () cnt ! mxt ! nes ! nec ! co ! jp>
Date:       2007-08-20 6:59:04
Message-ID: 46C93BB8.9040900 () cnt ! mxt ! nes ! nec ! co ! jp
[Download RAW message or body]

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" ) };
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic