One output stream to two dests 
Author Message
 One output stream to two dests

How can I send one output stream to two destinations in PERL?

In UNIX Bourne/Born Again:

$ cat thisone 2>&1.

In this case, I want output to go to a file and to stdout.

Please email replies.

Thanks in advance.



Sun, 26 Nov 2000 03:00:00 GMT  
 One output stream to two dests

On Wed, 10 Jun 1998 20:49:29 GMT, Josh Abrams wrote :

Quote:

>How can I send one output stream to two destinations in PERL?

>In UNIX Bourne/Born Again:

>$ cat thisone 2>&1.

>In this case, I want output to go to a file and to stdout.

$ cat thisone | tee somefile

Of course it isnt Perl and it will probably start the ToolWar back up
again but hey its easy to type.

However back in the dim and distant past Tom Christiansen made a post
that can be found on DejaNews thus:

Subject:      SOURCE: tee clone for process teeing

Date:         1998/02/12

Newsgroups:   comp.lang.perl.misc

Which might help.

/J\  
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



Sun, 26 Nov 2000 03:00:00 GMT  
 One output stream to two dests

    Josh> How can I send one output stream to two destinations in
    Josh> PERL?

    Josh> In UNIX Bourne/Born Again:
    Josh> $ cat thisone 2>&1.

    Josh> In this case, I want output to go to a file and to stdout.

Josh, your sh syntax does not do what you think.  2>&1 redirects
stderr to stdout.

You can do this yourself:

        open(OFILE, "/var/tmp/ofile") or die;
        open(PIPE, "cmd|") or die;
        while(<PIPE>) {
                print OFILE $_;
                print;
        }

This reads the output from cmd and prints to OFILE
and stdout.

--
Quentin Fennessy                        AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals



Mon, 27 Nov 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Two questions, one easy, one hard.

2. Two questions, one easy, one hard

3. two modules -- one in /usr/lib/perl5 one not

4. Working with two streams at once: ack pth!

5. How to take two input streams?

6. WANTED: many-to-one stream multiplexer

7. How to flush completed HTTP output stream?

8. Flushing the Output Stream

9. binary file output (textual hex to binary stream - wmf image file)

10. eof check on output stream

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

12. Streaming Media Streams

 

 
Powered by phpBB® Forum Software