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 Redirect the error messages from Syslog file to our own Application Log File balasubramaniam HP-UX 3 04-17-2008 02:44 PM
Error checking a file from previous file size stuck1 Shell Programming and Scripting 2 12-06-2007 08:39 AM
Redirecting to Error File lorcan UNIX for Advanced & Expert Users 1 10-12-2007 02:07 AM
Error: Internal system error: Unable to initialize standard output file firkus UNIX for Dummies Questions & Answers 2 10-25-2005 04:23 PM
File Error dreams5617 Shell Programming and Scripting 7 12-21-2004 01: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 08-30-2008
pradeepreddy pradeepreddy is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 66
error log file

I am running a script.

if in between due to any problem it fails I have to creat a error log file mentioning what was the error with date and time.

If script executed succesfully I have to create success log file.

Can u help me out. its urgent
  #2 (permalink)  
Old 09-01-2008
Annihilannic Annihilannic is offline Forum Advisor  
  
 

Join Date: May 2008
Location: Sydney, Australia
Posts: 1,009
You could do something like this:


Code:
if something was successful
then
      echo "$(date): successfully did something" > /tmp/success.log
else
      echo "$(date): something failed " > /tmp/error.log
      exit 1
fi

  #3 (permalink)  
Old 09-01-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Actually if something is competently written, its exit code should indicate whether or not it was successful; then you simply write


Code:
if something; then
  date +"%c: successfully did something"
else
  date +"%c: something failed"
fi >>/tmp/error.log

(Variations on output message formatting with date and the redirection flow simply to demonstrate that There Is More Than One Way To Do It.)
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 05:58 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