I got it working on the shell now:
savage@netsonic:~/src# perl -MIPC::Open2 -e'open2(*rd, *wr, "/bin/ls -al");
while (<rd>) { print; } exit;'
total 32
drwxr-x--- 8 root wheel 512 Jul 17 03:29 .
drwxr-xr-x 8 root wheel 512 Jul 16 05:38 ..
-rwxr-x--- 1 root wheel 21955 Jul 17 22:36 ApacheReconfig
drwxr-xr-x 5 640 15 1024 Jul 12 00:27 amavisd-snapshot-20020300
drwxr-x--- 2 root wheel 512 Jul 8 01:49 ftpmail
drwxr-x--- 4 root wheel 512 Jul 9 07:33 mrtg-2.9.21
drwxr-x--- 9 root wheel 1024 Jul 13 21:44 nagios-1.0b4
drwxr-x--- 6 root wheel 1024 Jul 11 08:07 netsaint-plugins-1.2.9-4
drwxr-x--- 7 root wheel 2560 Jul 11 05:41 tpop3d-1.4.2
However, when I call it from my perl script:
use strict;
use IPC::Open2;
open2(*rd, *wr, "/bin/ls -al");
while (<rd>) {
print $_;
}
Sure, there's allot of other stuff in the perl script, mainly allot of
database queries, and to open() / close() file handles, but needless to say,
when I use open2() like this from the command line, it works. Inside my
script it fails....
----- Original Message -----
From: "Tanton Gibbs" <[EMAIL PROTECTED]>
To: "Chris Knipe" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, July 17, 2002 10:27 PM
Subject: Re: executing binaries
> Chris Knipe wrote:
> > savage@netsonic:~/src# perl -MIPC::Open2 -e'open2($rd, $wr, "ls -al");
> while
> > (<$rd>) { print; } exit;'
> > open2: wtr should not be null at -e line 1
>
> It may have to do with the fact that you can't write to ls...the following
> worked for me
>
> use IPC::Open2;
> use strict;
>
> my ($rd, $wr);
> open2($rd, $wr, "bc");
> print $wr "5 + 7\n";
> my $x = <$rd>;
> print $x;
> close( $rd );
> close( $wr );
>
> Tanton
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]