Simple While Loop not exitting

Hi Experts,

Im running a bit complicated sql script and for reasons of scheduling,I wrapped it around in a simple shell script. So, when I run it, it do creates an output file and writes to it everytime I run it & this is what exactly I wanted.
However, it is not exiting the while loop no matter what I do. Here is what I have in my sql script.

#!/bin/ksh

A=1
while [ $A -lt 3 ];
do

echo 'Process Start'

sqlplus -s UID/PWD@DB @/Users/PGonzales/File.sql >>/Users/PGonzales/Filelog.log

echo "Writing to log file"

echo 'Process End'

A=`expr $A + 1`
done
exit

No matter what I do, it is not exitting the while loop and I have to ctrl^D to exit out. I tried my luck with if loop as well and even there, it is not exiting.

Please help
regards,
PGonzales.

Are you sure you have expr on that machine ?

Can you try this inside loop to increment

A=$(( $A + 1 ))

Also, put #!/bin/ksh -x and observe the output when you run the script.

Regards
Peasant.

Peasant,

You are so correct. I did which on the expr and it did not show anything under there. Thanks a bunch.

Appreciate your help and I cant believe that I was doing such a silly mistake.

This forum is truly a blessing for a novice like me.

regards,
PGonzales.

Odd in several ways.

expr has been around a long time and is part of POSIX. It seems to me unlikely that a system would not have it. Is there a UNIX platform out there in common use that does not provide expr?

If expr were indeed missing, the shell should have provided an error message (although perhaps stderr was redirected).

Finally, if there was indeed an infinite loop, control-d would not stop it. That merely sends EOF. control-c would be necessary to send a signal to terminate the foreground process group. control-d would only have an effect if something is hanging while waiting on input.

Regards,
Alister

echo $PATH and uname -a would be illuminating.