[Top][All Lists]

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

mkfifo and tee within a function

From: Nathan Coulter
Subject: mkfifo and tee within a function
Date: Tue, 28 Nov 2006 07:13:17 -0500
User-agent: Thunderbird (Windows/20061025)


Within a function, I'd like to print some input to the terminal and at the same time 
store it in a fifo fostore some input in a fifo,  but am getting mixed results.  In this 
example, I thought "hello" would be output twice:

$>cmd_print () { mkfifo zout ; (tee zout &); cat zout ; rm zout; }
$>printf 'hello\n' | cmd_print

This outputs "hello" twice:

$>cmd_print () { mkfifo zout ; (cat - | tee zout &); cat zout ; rm zout; }
$>printf 'hello\n' | cmd_print

but this doesn't output anything:

$>cmd_print () { mkfifo zout ; (cat - | tee zout &) ; rm zout; }
$>cmd_print <<EOF
$> date
$> EOF

My real goal is to feed data to a function and then source it:
$> cmd_print () { mkfifo zout ; (cat - > zout ) & ; source zout ; rm zout; }
$> cmd_print <<EOF
$> date
$> EOF

Could anyone please provide a few pointers on how to accomplish this, and 
perhaps explain the results from the above examples?

reply via email to

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