capturing output of piped commands 
Author Message
 capturing output of piped commands

If I tell my script to pipe to the shell and run 'grep', how can I
capture the output. Is is considered <STDIN> if the script is CGI and is
run from Netscape? Example:

open (DOIT, "|/usr/bin/grep *.html");

Now, how can I use what 'grep' would otherwise return to the screen, and
must I parse it one line at a time?

Thanks,  Craig.



Tue, 02 Dec 1997 03:00:00 GMT  
 capturing output of piped commands

Quote:
>If I tell my script to pipe to the shell and run 'grep', how can I
>capture the output. Is is considered <STDIN> if the script is CGI and is
>run from Netscape? Example:
>open (DOIT, "|/usr/bin/grep *.html");
>Now, how can I use what 'grep' would otherwise return to the screen, and
>must I parse it one line at a time?

You have the | symbol at the wrong end of the command: if you put it
at the end, "open" will create a file handle form which you can read
the lines you want:

        open (DOIT, "/usr/bin/grep pattern *.html |");
        while (<DOIT>) {
                &parse($_);
        }
        close DOIT;

--
Hope this helps,

HansM



Sat, 06 Dec 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Help with Piped command, capturing output

2. capturing command line error or output from `<command>`

3. Help: capturing pipe output

4. Newbie trying to capture(control) output from pipe

5. Help: capturing pipe output

6. Non-intermeshing output streams when capturing STDOUT in a pipe

7. capturing output of FILEHANDLE "| command"

8. capturing output from a remote command (how?)

9. Capturing System Command Output with Perl on Windows/Apache

10. capturing output of executed system command

11. Capture command output into list?

12. Capturing output of a system command

 

 
Powered by phpBB® Forum Software