The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-02-2007
nsutti nsutti is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 3
Question Putting screen output in a log file

I want to output screen messages to a logfile when executing an automated script. I have tried the script and command to do this but with no luck.

Thanks,
Nicole
  #2 (permalink)  
Old 11-02-2007
the_anthroid the_anthroid is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 1
i assume you've tried calling the script as:

scriptname -options > outputfile.txt

?
  #3 (permalink)  
Old 11-02-2007
nsutti nsutti is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 3
unix script

This did not work, the program bombed out and put out my standard output. Not sure if this is valid for unix script. It did not like the scriptname.

Thanks
  #4 (permalink)  
Old 11-02-2007
matrixmadhan matrixmadhan is offline Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,958
the errors might have been meant for stderr rather than stdout

try this,


Code:
programname > logfile 2>&1

  #5 (permalink)  
Old 11-05-2007
gus2000 gus2000 is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 157
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.
  #6 (permalink)  
Old 11-06-2007
nsutti nsutti is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 3
thanks so much

This script worked. Thanks to all of you who helped.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:08 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0