my $out = `cmd-to-run 2>&1`; # Should really check command return code via $? special variable here # Then print $out via your $tee here # Note: 2>&1 (to fold stderr into stdout) works fine on Windows XP #### open(my $fh, 'cmd-to-run 2>&1 |') or die "open error: $!"; while (<$fh>) { # print $_ via your $tee here } close($fh) or die "close error: $!";