B
Bryan K. Wright
Hi folks,
The following seems simple, but it's driving me crazy.
I'd like to create a command pipe with open, like this:
open ( CMD, "mycommand |");
then print out each line of the command's output AS IT HAPPENS.
Here's what I've tried:
#!/usr/bin/perl
use strict;
use FileHandle;
STDOUT->autoflush(1);
open ( COMMAND, "mycommand |" ) or die "Can't run command: $!\n";
COMMAND->autoflush(1);
while (<COMMAND>) {
print;
}
close ( COMMAND );
But the command's output is still buffered until the command
finishes. What am I doing wrong here?
Thanks,
Bryan
--
===============================================================================
Bryan Wright |"If you take cranberries and stew them like
Physics Department | applesauce, they taste much more like prunes
University of Virginia | than rhubarb does." -- Groucho
Charlottesville, VA 22901 |
(434) 924-7218 | (e-mail address removed)
===============================================================================
The following seems simple, but it's driving me crazy.
I'd like to create a command pipe with open, like this:
open ( CMD, "mycommand |");
then print out each line of the command's output AS IT HAPPENS.
Here's what I've tried:
#!/usr/bin/perl
use strict;
use FileHandle;
STDOUT->autoflush(1);
open ( COMMAND, "mycommand |" ) or die "Can't run command: $!\n";
COMMAND->autoflush(1);
while (<COMMAND>) {
print;
}
close ( COMMAND );
But the command's output is still buffered until the command
finishes. What am I doing wrong here?
Thanks,
Bryan
--
===============================================================================
Bryan Wright |"If you take cranberries and stew them like
Physics Department | applesauce, they taste much more like prunes
University of Virginia | than rhubarb does." -- Groucho
Charlottesville, VA 22901 |
(434) 924-7218 | (e-mail address removed)
===============================================================================