develooper Front page | perl.beginners | Postings from December 2003

Re: How to send O/P to file?

Thread Previous | Thread Next
From:
drieux
Date:
December 24, 2003 18:02
Subject:
Re: How to send O/P to file?
Message ID:
63A4B114-367E-11D8-8283-0030654D3CAE@wetware.com

On Dec 24, 2003, at 2:03 PM, R. Joseph Newton wrote:
[..]
>
> use strict;
> use warnings;
>
> my @remote_cmd_list = ('print "Hello, world!\n";');
>
> # my $foo_bar = Net::Foo::Bar->new(@net_connect_stuff);
> my $filename = 'debug_runs/debug_' . time  . '.log';
>
> {
>    open DEBUG_LOG,  ">$filename" or die "Couldn't output to debug log:
> $!";
>    local *STDOUT = *DEBUG_LOG;

wouldn't you also want

	local *STDERR  = *DEBUG_LOG;

so as to 'trap' the possibility that it
was printing to stderr as well?

>    foreach my $cmd (@remote_cmd_list)
>      {
>         do_remote($cmd);
>      }
> }
[..]

> Which should allow normal IO to continue as soon as output from the
> commands has been captured.

I personally would want to have a bit more
coherency in my Net::Foo::Bar so that if
we need to do a 'tee_output()' that it
would have a mechanism for doing the
send to log_logfile and straight out
the door to the command line.

Either that or I would probably want it
to be returning to the code the responses
that it got back from the far server ....



ciao
drieux

---


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About