The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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
Top level TCSH while Loop doen't work sprynmr UNIX for Dummies Questions & Answers 2 01-23-2009 09:07 AM
Seek UNIX script tutor and help duke0001 UNIX for Advanced & Expert Users 2 05-12-2008 12:08 PM
The loop that dosent work jadionne UNIX for Dummies Questions & Answers 12 01-11-2008 09:25 AM
Modify Perl script to work with txt - Permissions script joangopan Shell Programming and Scripting 1 09-13-2007 12:38 AM
Script doesn't work, but commands inside work cheongww UNIX for Dummies Questions & Answers 2 11-14-2006 10:52 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 10-15-2006
duke0001 duke0001 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 131
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 07:59 PM..
  #2 (permalink)  
Old 10-15-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,122
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.
  #3 (permalink)  
Old 10-16-2006
duke0001 duke0001 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 131
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?
  #4 (permalink)  
Old 10-16-2006
duke0001 duke0001 is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 131
Perderabo:

You are right. "If" caused the problem. Thanks for your help.
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 07:55 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