[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to safely pipe output to tee?

From: Steven W. Orr
Subject: How to safely pipe output to tee?
Date: Mon, 07 Mar 2011 13:31:35 -0500
User-agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv: Gecko/20110303 Thunderbird/3.1.9

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 &
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?


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

[Prev in Thread] Current Thread [Next in Thread]