Re: Logging of commands in a bash script to a file
Daniel Bareiro <daniel-listas@gmx.net> wrote:
> What I meant is to have a group of commands in a script that, in
> addition to being executed, I want these commands are stored in a log.
LOG=/var/log/...logfile...
ExecAndLog()
{
# Season with date, PID, user, etc., to taste
echo "$*" >>"$LOG"
"$@"
# Could capture $? (exit status), stdout, stderr, etc. if desired
}
# ...later...
ExecAndLog $IP route add ...whatever...
ExecAndLog $IP route add ...whatever...
ExecAndLog $IP route add ...whatever...
Chris
Reply to: