in reply to Re: Executing command from perl script with input/output
in thread Executing command from perl script with input/output
In the above, the program seems to be waiting for some kind of input after it prints the PID - never enters the foreach loop. How can I solve the above problem?sub ExecCmd { my $cmd = shift; my $pid = open3(\*WRITE,\*READ,\*ERROR,$cmd); unless (defined $pid) { LogError("Failed to execute $cmd"); return undef; } LogInfo("PID is $pid"); my $select = new IO::Select(); $select->add(\*READ); $select->add(\*ERROR); foreach my $handle ($select->can_read) { LogInfo("handle is $handle"); my $buf = ""; if($handle eq \*ERROR) { sysread(ERROR,$buf,BUFFER); close ERROR; if($buf) { LogInfo("ERROR -> $buf"); } } else { sysread(READ,$buf,BUFFER); close READ; if($buf) { LogInfo("READ -> $buf"); } } } print WRITE "0\n";
Thanks!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Executing command from perl script with input/output
by zentara (Cardinal) on Aug 09, 2005 at 11:25 UTC | |
by linuxfan (Beadle) on Aug 09, 2005 at 19:48 UTC | |
by zentara (Cardinal) on Aug 10, 2005 at 11:30 UTC | |
by linuxfan (Beadle) on Aug 10, 2005 at 18:26 UTC | |
by zentara (Cardinal) on Aug 11, 2005 at 10:27 UTC | |
|