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