On 3/7/2011 2:02 PM, Micah Cowan wrote:
(03/07/2011 10:31 AM), Steven W. Orr wrote:
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.
It seems to me that tee hangs around because its pipe is still open on
the other end (courtesy of these background processes you mention).
In that case, can't you just redirect all these background processes, so
that they're not writing to that same stdout file descriptor?
For instance,
foo='sleep 100&'
poses an issue, but
foo='sleep 100>&- 2>&-&'
shouldn't.
Sorry, but I'm not sure I see why this helps.
I think it says (I assume you meant a space between the 100 and the greater
than, otherwise you're just trying to close channel 100):
foo='sleep 100 >&- 2>&- &'
"Sleep for 100 seconds and then close channel 1 and channel 2."
Maybe. But how do I harvest the status of the command, since the sleep will
always succeed?
--
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