quoted print?
Rick Cooper
rcooper at DWFORD.COM
Tue Nov 9 12:15:27 GMT 2004
> -----Original Message-----
> From: MailScanner mailing list [mailto:MAILSCANNER at JISCMAIL.AC.UK]On
> Behalf Of Julian Field
> Sent: Tuesday, November 09, 2004 6:34 AM
> To: MAILSCANNER at JISCMAIL.AC.UK
> Subject: Re: quoted print?
>
>
> 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.
>
>
<snip>
This won't work, this will
#!/bin/sh
cat /dev/null > script.out
echo This is a script 2>&1 | tee -a script.out
echo This is line 1 2>&1 | tee -a script.out
ls 2>&1 | tee -a script.out
# This will produce stderr output
ypmatch wibble ecsinfo 2>&1 | tee -a script.out
echo This is the end. 2>&1 | tee -a script.out
I see what you are trying to do so this would probably be your best answer:
#!/bin/sh
# clear the out file, and/or create it
cat /dev/null > script.out
# Set done to NO at the top of the script so the following loop
# will execute. Wrap your entire script in this loop
DONE=NO
until [ "$DONE" = "YES" ]
do
echo This is a script
echo This is line 1
ls script.out
# This will produce stderr output
ypmatch wibble ecsinfo
echo This is the end.
# now at the bottom of the loop set DONE to YES so the loop won't execute
# again
DONE=YES
# This wraps the entire loop output so stderr goes to stdin then pipes to
tee
# which in turn appends all output to script.out
done 2>&1 | tee -a script.out
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
------------------------ 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