Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- PROGNAME=$(basename $(readlink -f $0))
- LOG="output-$PROGNAME.log"
- _output_echo () {
- while read data; do
- echo -e "$PROGNAME: $data"
- echo -e $data | _output_file
- done
- }
- _output_file () {
- while read data; do
- echo -e "$PROGNAME: $data" >> $LOG
- done
- }
- # program output to log file and optionally echo to screen (if $1 is "-e")
- log () {
- if [ "$1" = '-e' ]; then
- shift
- $@ | _output_echo
- else
- $@ | _output_file
- fi
- }
- log echo "Log File Only"
- log -e echo "Echo & Log File"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement