From: kolmogolov on
Hi,

would you please help with file descriptor
manipulation?

I tried to manifest what I want to do
in the subject line.

In order to log the output of my

/etc/init.d/local

I'd like to be able to have a script
output to both the screen and
append to a logfile.

But I'll need a header part and a trailer
part as follows and I'm not comfortable
with the sleep(1).

How would you redirect simultaneously
to two files, the tty and a logfile?

-----------------------------
#!/bin/sh
tail -f /tmp/logfile &
PID=$!
exec >> /tmp/logfile 2>&1

echo stdout
echo >&2 stderr

sleep 1 # This seems to be necessary....
kill $PID
-----------------------------

My thanks in advance for your help!
regards
From: Michael Tosch on
kolmogolov(a)gmail.com wrote:
> Hi,
>
> would you please help with file descriptor
> manipulation?
>
> I tried to manifest what I want to do
> in the subject line.
>
> In order to log the output of my
>
> /etc/init.d/local
>
> I'd like to be able to have a script
> output to both the screen and
> append to a logfile.
>
> But I'll need a header part and a trailer
> part as follows and I'm not comfortable
> with the sleep(1).
>
> How would you redirect simultaneously
> to two files, the tty and a logfile?
>
> -----------------------------
> #!/bin/sh
> tail -f /tmp/logfile &
> PID=$!
> exec >> /tmp/logfile 2>&1
>
> echo stdout
> echo >&2 stderr
>
> sleep 1 # This seems to be necessary....
> kill $PID
> -----------------------------
>
> My thanks in advance for your help!
> regards

#/bin/sh
(
# sub shell
echo stdout
echo >&2 stderr
) 2>&1 | tee logfile

--
echo imhcea\.lophc.tcs.hmo |
sed 's3\(....\)\(.\{5\}\)3\2\132;s2\(.\)\(\)\(.\)2\3\12g;1s;\.;::;2'