S
sp0_0ky
Hello,
I have a program which generates many lines of output. I only
need the first few (say 10) lines from the top of the output.
I do not require the program to complete all the output (just
need the first few lines).
The following seems to work, however it complains about "Broken
Pipe" since I am closing the pipe once I get the required data.
I was wondering if there is a cleaner way to do this. The key
is that I do not want to wait for the data command to complete.
open(LOTSOFLINES,"mycommand 2>&1|");
count=0;
while (<LOTSOFLINES>)
{
print;
count++;
if ($count > 10)
{
close(LOTSOFLINES);
}
}
Thanks,
JB
I have a program which generates many lines of output. I only
need the first few (say 10) lines from the top of the output.
I do not require the program to complete all the output (just
need the first few lines).
The following seems to work, however it complains about "Broken
Pipe" since I am closing the pipe once I get the required data.
I was wondering if there is a cleaner way to do this. The key
is that I do not want to wait for the data command to complete.
open(LOTSOFLINES,"mycommand 2>&1|");
count=0;
while (<LOTSOFLINES>)
{
print;
count++;
if ($count > 10)
{
close(LOTSOFLINES);
}
}
Thanks,
JB