I want to compute a command string which will end up in foo.

Then I want to run that command and cause stdout and stderr to be piped to tee for safe keeping while it also goes to the screen.

After the command finishes, I need tee to exit.

It sounds easy, but it's not.

eval "$foo" 2>&1 | tee filename

will cause a hang. Why? Because what $foo does is to start lots of child processes and services which do not end. I just want to proceed to the next command as soon as $foo completes.

I have the Kudge O The Day currently running, but I'd love to see something better. My current setup is this:

mkfifo fifoname
tee filename < fifoname &
teepid=$!
eval "$foo" > fifoname 2>&1
kill $teepid
rm fifoname

And also, BTW, I do need the exit status of the executed command.

Anyone have a better idea?

TIA

--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net

Reply via email to