![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to print script output to screen and file | orahi001 | UNIX for Dummies Questions & Answers | 10 | 01-16-2009 01:47 AM |
| no screen output | wisher115 | UNIX for Dummies Questions & Answers | 0 | 09-17-2006 12:25 PM |
| Turn off Screen Output | bestbuyernc | Shell Programming and Scripting | 3 | 10-06-2005 06:08 PM |
| screen output | gundu | Shell Programming and Scripting | 1 | 03-15-2005 12:31 PM |
| Supress screen output... | jagannatha | UNIX for Dummies Questions & Answers | 3 | 04-24-2003 03:17 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
Saving the output of unattended scripts
I put this into all of my unattended scripts: Code:
# Send all output to a logfile and supress input
typeset LOG="/tmp/${0##*/}.out"
mv $LOG ${LOG}.old >/dev/null 2>&1
[[ -t 1 ]] && echo "Writing to logfile '$LOG'."
exec > $LOG 2>&1
exec < /dev/null 2<&1
All stdout and stderr will be logged. Also, since stdin is closed, the script won't hang if any commands wait for input. It will report the logfile name to stdout if run from the command line (attached to a terminal). This should essentially work the same as the redirection code offered above. If neither is working then something else is wrong, and you'll need post more info about the error. |
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|