The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Seek UNIX script tutor and help duke0001 UNIX for Advanced & Expert Users 2 05-12-2008 08:08 AM
The loop that dosent work jadionne UNIX for Dummies Questions & Answers 12 01-11-2008 06:25 AM
Modify Perl script to work with txt - Permissions script joangopan Shell Programming and Scripting 1 09-12-2007 08:38 PM
Script doesn't work, but commands inside work cheongww UNIX for Dummies Questions & Answers 2 11-14-2006 07:52 PM
Top level TCSH while Loop doen't work sprynmr UNIX for Dummies Questions & Answers 1 02-04-2005 02:25 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 10-14-2006
Registered User
 

Join Date: Nov 2005
Posts: 127
Why script For...Loop doesn't work. Seek help

I have written a script to run on UNIX server. When I tested, it always hanged on after "date +"%D %T: XXXXXX script started." part. Then it wouldn't go further. UNIX server gave me one error message. I used the same code in another script. It works fine. I think the major problem may be in For...Loop part. The script can not access into the $filename. I post code and error message here. Please help me to figure out where the bottleneck is. Thanks a lot

# Started DB Job on xxx table.
for filename in directory_name/xxx_*.sql
do
sqlplus -s > temp.log 2>&1 dbuser/pswd@$ORACLE_SID @$filename

If [ $? = 0]
then date +"%D %T: $filename successully executed." >> xxxx.log
else date +"%D %T: Error executing $filename." >> xxxx.log
grep "ORA-" temp.log >> xxxx.log
date +"%D %T: Exiting script." >> xxxx.log
mail -s 'XXXX execution: Unsuccessful. See log file for errors.' mymail@company.com<xxxx.log
exit 1
fi
done

# Delete temp.log file
rm -f temp.log

mail -s " XXXX execution: Successful" mymail@company.com <xxxx.log

exit 0

Last edited by duke0001; 10-16-2006 at 03:59 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 10-14-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
Quote:
If [ $? = 0]
You cannot capitalize keywords. You need to use "if", not "If". And the brackets must be surrounded by white space. You need a space bewteen the zero and the closing bracket.
Reply With Quote
  #3  
Old 10-16-2006
Registered User
 

Join Date: Nov 2005
Posts: 127
Thanks for your advise. something was typo. Could you please point out the coding problem in the script. Do I need to declare a envirnment variable to point to that directory? Is there any problem in wildcard for file name?
Reply With Quote
  #4  
Old 10-16-2006
Registered User
 

Join Date: Nov 2005
Posts: 127
Perderabo:

You are right. "If" caused the problem. Thanks for your help.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 04:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0