in reply to Print STDOUT and STDERR to file and to console
But the basic version to split output is not hard:
Yep, that's pretty much it. Open for append if you like.#!usr/bin/perl -w use strict; $|=1; #turn autoflush on #tee.pl sub usage () { print "TEE USAGE:\n". " program | tee outfile\n". " sends stdout from program to outfile\n"; exit; } my $filename = shift @ARGV; usage unless $filename; open (OUTFILE, ">", "$filename") or (die "Can't open OUTFILE: $!"); while (<>) { print; print OUTFILE; }
|
|---|