Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Teeing output from a script

0 views
Skip to first unread message

Richard Pavlik

unread,
Sep 25, 1997, 3:00:00 AM9/25/97
to

Hi, I know this has been answered before, but here is my problem:

I want a script to output both to stdout and a file. I don't want to
call
the script piped into tee. I want the script to do it itself. I know the
soloution requires the exec command with some funky io redirecrion.

Tnx
--

********************************************************************
Richard Pavlik Shell Canada Limited
Sr. Systems Analyst 400 - 4th Ave. S.W. Rm. 1145
Phone: (403)691-4769 P.O. Box 100, Station M
Fax: (403)269-7505 Calgary, Alberta, Canada
e-mail: Pavlik_Richard/sc...@shell.ca T2P 2H5
********************************************************************

Steve W. Jackson

unread,
Sep 25, 1997, 3:00:00 AM9/25/97
to

In article <342A84...@shell.ca>, Richard Pavlik
<Pavlik_Richard/SC...@shell.ca> wrote:

:> Hi, I know this has been answered before, but here is my problem:

I'm not in a position to get to my system and check, but the kind of thing
you're talking about involves creating additional file descriptors using
the exec command. Something like exec 3>file will associate file
descriptor 3 with the named file. The trouble is, individual commands in
your script will still have to be redirected to both stdout and FD 3, or
you'll have to tee each of them. Offhand, I can't think of any way to
open a file descriptor and cause all stdout to go both to 1 and 3. Maybe
someone here can fill in whatever I might be forgetting.

Lotsa luck.

= Steve =

--
Steve W. Jackson
Montgomery, Alabama
sja...@mindspring.com
http://www.mindspring.com/~sjacksn/stevehome.html

Do you believe in Macintosh? Learn how to help the
cause by subscribing to the "EvangeList" listserver!
Send email to <evang...@macway.com> or check out
<http://www.solutions.apple.com/ListAdmin/>.

Chukk Haselhorst

unread,
Sep 26, 1997, 3:00:00 AM9/26/97
to

I don't know how to redirect output to a file and stdout at the same time
but the following
shows how to use exec to send output to a file from within a script...

# Save the stdout and stderr file descriptors for later use
exec 5<&1
exec 6<&2

# Redirect all *default* stdout and stderr to a file. Output that is
specifically
# directed will go to where it is commanded to go. All other output is
# routed to the $ErrMsg file.
exec 1>>$ErrMsg
exec 2>&1

# Reset the stdout and stderr
exec 1>&5
exec 2>&6

Chukk Haselhorst

>Richard Pavlik <Pavlik_Richard/SC...@shell.ca> wrote in article
<342A84...@shell.ca>...

0 new messages