quoted print?
Julian Field
mailscanner at ecs.soton.ac.uk
Tue Nov 9 11:33:31 GMT 2004
I've tried that. Zero-length file.
#!/bin/sh
echo This is a script
exec 2>&1 | tee script.out
echo This is line 1
ls
ypmatch wibble ecsinfo # This will produce stderr output
echo This is the end.
On 9/11/04 11:18 am, "Richard Brown" <mynamewasgone at gmail.com> wrote:
> On Tue, 9 Nov 2004 10:21:45 +0000, Julian Field
> <mailscanner at ecs.soton.ac.uk> wrote:
>> Any idea how to do this? My sh isn't good enough. I can redirect the stderr
>> of the script to its stdout with "exec 2>&1", but how do I redirect the
>> stdout through "tee" which is presumably what I need to do to get the output
>> into a file as well as on the terminal. "exec |tee file.out" is obviously
>> not right.
>
> Put them together
>
> exec 2>&1 | tee file.out
>
> 2>&1 redirects stderr to stdout, then the pipe redirects stdout, which
> now also includes stderr
--
Julian Field
www.MailScanner.info
Buy the MailScanner book at www.MailScanner.info/store
PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654
------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).
More information about the MailScanner
mailing list