Reputation: 1709
I've noticed a couple other questions about handling this, but all seem to suffer from:
What I would like to do is call a program (eg. tshark.exe) and process its output while it runs.
To date I have tried:
all without any success. I could spend all day trying and failing to find a module which helps me with this (ie. I have spent all day), but I figured it might be better if I just asked if anyone knew of one.
Upvotes: 1
Views: 239
Reputation: 118685
You don't need a module. Just learn about the pipe forms of the open
command -- these work just fine on Windows.
my $pid = open (my $cmd_handle, "tshark.exe @options |");
# on success, $pid holds process identifier of the external command.
while (<$cmd_handle>) {
# sets $_ to next line of output.
# Will block until a line of output is ready.
# Is undef when the command is complete.
... process $_ ...
}
close $cmd_handle; # waits for command to complete if it hasn't completed yet
Upvotes: 4
Reputation: 1271
Check out IPC::Run
. IPC::Open2
and IPC::Open3
might meet your needs too.
Good luck!
Upvotes: 0