Massyn has asked for the wisdom of the Perl Monks concerning the following question:
#!/fellow/monks.pl
I would like to execute another application from within Perl. Using the system() and back ticks works ok if it's a one time run, but what if it's a constant running application, giving me output all the time?
I want to execute a program and parse the output of that program line by line. My piece of code I have here doesn't work so well. The program executes, but it never returns the output, possibly because it's waiting for the program to terminate before doing so, unfortunatly, that's not what I want. I want to get the output line by line in my foreach loop for parsing. Any suggestions?
I appreciate any Perl's of Wisdom the monks can send my way.
open(READ, "-|", "someoscommand.exe"); foreach $a (<READ>) { chomp($a); print "==> $a\n"; } close READ;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: OS command execution
by Massyn (Hermit) on Oct 14, 2002 at 07:26 UTC | |
by fsn (Friar) on Oct 14, 2002 at 16:06 UTC |