Ken Foskey wrote:
On Mon, 2007-09-24 at 05:13 +0530, Somu wrote:
Thanks for the help. I did it using

 system "tasklist >> temp";

 open FH , "temp" ;
 statements..
unlink ("temp"); #EOF

Consider this code snippet then, does this in one step.  I am writing
the output to a log only you can put all the logic into the loop.

        open( $process, '|-', $command ) or croak "Unable to create process
$command, $!";
        while( $line = <$process> ) {

You are opening $command for piped *input* but you are trying to read from it? Perhaps you meant:

open( $process, '-|', $command ) or croak "Unable to create process $command, $!";


                print $log $line;
        }
        close( $process );

You should also verify that the pipe closed successfully:

        close( $process ) or warn $! ? "Error closing '$command' pipe: $!"
                                     : "Exit status $? from '$command'";




John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to