add kvpairs2td
[hband-tools.git] / user-tools / logto
blob40fc8d3a85fe1dfbee0e19a3524e4f04c2714c05
1 #!/bin/bash
3 true <<EOF
4 =pod
6 =head1 NAME
8 logto - Run a command and append its STDOUT and STDERR to a file
10 =cut
12 EOF
15 if [ ".$1" = ".--help" ]
16 then
17 echo "Usage: $0 <FILENAME> <COMMAND> [<ARGS>]"
18 echo "Save command's output (stdout and stderr) to file and keep normal stdout and stderr as well."
19 exit
22 set -e
23 set -o pipefail
24 set -u
26 logfile=$1
27 shift
29 exec "$@" 2> >(tee -a "$logfile" >&2) | tee -a "$logfile"