Click to See Complete Forum and Search --> : shell script to tee ITSELF
Morphine Drip
12-10-2008, 04:29 PM
greetings all,
I have a shell script that I would like to log to stdout and also to a file.....much like using tee. I would like to, instead of calling the script and piping to tee...i would like for the script to tee itself.
thanks,
drip
Morphine Drip
12-10-2008, 05:01 PM
rm PIPE1
mkfifo PIPE1
#cat >logfile1 <PIPE1 &
cat <PIPE1 &
rm PIPE2
mkfifo PIPE2
cat >logfile2 <PIPE2 &
#cat <PIPE2 &
rm PIPE0
mkfifo PIPE0
tee PIPE1 >PIPE2 <PIPE0 &
exec 1>PIPE0 2>&1
from...
http://wiki.linuxquestions.org/wiki/Tee
bwkaz
12-12-2008, 02:03 AM
Um, why go to all that? Just do:
(
# this is a subshell
echo "blah blah blah"
# run whatever else
) | tee /path/to/file in the script.
lugoteehalt
12-19-2008, 10:21 AM
Probably misunderstanding but 'tee-ing itself': Appart from throwing a bucket of cold water over it how about: tee $0 ??
bwkaz
12-20-2008, 02:48 AM
how about: tee $0 ?? Um, feel free to try that, if you don't mind (a) crashing the shell if the script doesn't get cached, and/or (b) destroying the script the first time it runs...
You do not want to overwrite the script with something else... ;)