Thank you for your response.
I will try it with IPC::Open3.
I'm trying to create a simple example for IPC::Open3. Should I create a separate post relating to getting Open3 to work?
Below is code I am trying and here is the output I get:
OUTPUT:
err-> /bin/ls: write error: Bad file descriptor retval-> 512
CODE:
#!/usr/bin/perl
use warnings;
use strict;
use IPC::Open3;
print "Content-type: text/html\n\n";
print ' <!DOCTYPE HTML>
<html lang="en">
<head>
<title>IPC::Open3 Example</title>
</head>
<body>';
my $cmd = '/bin/ls -la';
my $pid = open3(\*WRITER, \*READER, \*ERROR, $cmd);
while( my $output = <READER> ) {
print "output-> $output\n";
}
while(my $errout = <ERROR> ) {
print "err-> $errout\n";
}
waitpid($pid, 0 ) or die "$!\n";
my $retval = $?;
print "retval-> $retval\n";
print " </body>
</html>";
|