Register
It is currently Sun Apr 20, 2014 11:05 pm

A hack to switch between output, logging or discarding


All times are UTC - 6 hours


Post new topic Reply to topic  [ 2 posts ] 
Author Message
 PostPosted: Fri Jan 29, 2010 3:49 pm   

Joined: Sat Jan 23, 2010 7:54 am
Posts: 5
This is what I'm using as a header in all the scripts I write now. It makes it easy to adapt scripts on the fly.

Further improvements I'm going to make, when I have time:
Make the script read a central configuration file that specifies which one of the following three modes it should use, so I can
easily switch all my scripts between debugging and discarding information.
Possibly make it so the configuration file has an entry for each script so they can look up to see what mode they should function
under (using the $0 parameter)

Code:
#       Log all output to a file for later viewing (For Cron jobs that need monitoring)
OUTPUT=/home/manu/runlog
#       Don't echo anything at all (For Cron jobs that have been tested sufficiently and don't need to show up in the log)
# OUTPUT=/dev/null
#       For when I run it myself from the commandline and want to see all output.
# OUTPUT=/dev/stdout

## Code with, for example:
echo "Download completed" >> $OUTPUT
echo "The year is $(date +%Y), and the time is $(date +%T)" >> $OUTPUT


Top
 Profile  
 PostPosted: Tue Feb 02, 2010 7:34 am   
User avatar

Joined: Mon Jan 18, 2010 8:10 pm
Posts: 40
Sounds very interesting! Could be very useful!

Please let us know how it goes.

g


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP