in reply to equivalent to prove?

There is a standard program called "tee" that does this. There all sorts of versions of this that you can download in a directly executable format. Below is a simple version written in Perl. Typical output buffer is about 4K bytes. You don't need to turn output buffering off if your program is generating lots of output - buffer gets flushed when it is full. There are various options on standard "tee" to append, overwrite, etc. This is just an example of what it does.

basic sytanx: $someprog | tee somefile

#file: tee.pl use strict; use warnings; $| = 1; # **** turn off output buffering ***** sub usage () { print "TEE USAGE:\n tees stdout to a file and to stdout\n". " program | tee outfile\n". " sends stdout from program to outfile\n"; exit; } my $filename = shift @ARGV; usage unless $filename; open (OUTFILE, ">>$filename") || die "Can't open OUTFILE: $!"; while (<>){ print; print OUTFILE; }

Replies are listed 'Best First'.
Re^2: equivalent to prove?
by Marshall (Canon) on Jan 30, 2009 at 12:27 UTC
    I may not have gotten exactly the gist of what you wanted here, but cat tee.pl | tee junk >anotherprog would run cat on tee.pl, save stdout in junk and pass it on to anotherprog. In this case, nothing gets printed to the screen (unless you tee again, which is also possible!).

      Nope, that tells it to write the output to 'anotherprog'. To do what you described, you'd want:

      cat tee.pl | tee junk | anotherprog