Debian Codegraph @

logging-wrapper.sh

raw symbols SCIP
1 #!/bin/bash
2 # logging-wrapper.sh
3 # Generic shell wrapper that performs an operation
4 #+ and logs it.
5
6 DEFAULT_LOGFILE=logfile.txt
7
8 # Set the following two variables.
9 OPERATION=
10 # Can be a complex chain of commands,
11 #+ for example an awk script or a pipe . . .
12
13 LOGFILE=
14 if [ -z "$LOGFILE" ]
15 then # If not set, default to ...
16 LOGFILE="$DEFAULT_LOGFILE"
17 fi
18
19 # Command-line arguments, if any, for the operation.
20 OPTIONS="$@"
21
22
23 # Log it.
24 echo "`date` + `whoami` + $OPERATION "$@"" >> $LOGFILE
25 # Now, do it.
26 exec $OPERATION "$@"
27
28 # It's necessary to do the logging before the operation.
29 # Why?