in reply to Capturing all (and I mean all) output to a file

The line perl scriptname.pl >outfile redirects STDOUT to the file. Anything written to STDERR is written to the screen.

The standard file handles are numbered in windows as they are in UNIX. STDIN=0, STDOUT=1, STDERR=2. Try tying together STDOUT and STDERR on the command line as part of the redirection to a file. the following code illustrates the point.

#! /usr/bin/perl -w # use strict; use warnings; print "Standard Out\n"; print STDERR "Standard Error\n";
Run using the command line:
myScript.pl >out.txt 2>&1

If you are working with Windows but you need to use a Unix tool then most of them have been ported. Try Unix Utils from SourceForge http://unxutils.sourceforge.net/. The tee command is available for you to use.

Replies are listed 'Best First'.
Re^2: Capturing all (and I mean all) output to a file
by flippy (Novice) on Jan 12, 2005 at 15:57 UTC

    I used the following in the end, using tee.exe - thanks for your tip!

    $|++; open (STDERR, ">&STDOUT"); #stuff my $cmdout = `system command`; print $cmdout;

    And ran it using

    perl code.pl |tee outfile.txt