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
while loop inside while loop panknil Shell Programming and Scripting 0 01-07-2008 12:49 PM
For loop xramm HP-UX 3 10-10-2007 03:20 PM
While Loop hemangjani Shell Programming and Scripting 2 11-02-2006 11:01 AM
for loop munnabhai1 Shell Programming and Scripting 3 04-06-2006 03:30 PM
how to get the similar function in while loop or for loop trynew Shell Programming and Scripting 3 06-17-2002 12:09 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-03-2005
whited05 whited05 is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 9
while loop

I have the following script I need to exit the look when 1hr expires or the sql statemnt comes back successfully (i.e. return 0) It seams my variable $CTR is not incrementing and I'm not sure why. Any help is appriciated

#! /usr/bin/ksh
CTR=0
RC=10
while [ $CTR -ne 6 -o $RC -ne 0 ]; do
let "$CTR = $CTR + 1"
echo $CTR
sqlplus -s $USER/$PW@$SID @ndm_file_check.sql stmt1
RC=$?
if [ $RC -ne 0 ]
then
sleep 600
fi
done

exit 0
  #2 (permalink)  
Old 11-03-2005
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,131
loose the quotes and the '$'-s....
  #3 (permalink)  
Old 11-03-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,131
let "$CTR = $CTR + 1"

You should not use dollar signs with let and you must not use a dollar sign with the lvalue.

let "CTR=CTR+1"

and rather than let, the double parentheses notation is better, although "let" is not actually incorrect.

((CTR=CTR+1))
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 02:26 PM.


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