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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
for loop syntax trouble visitorQ Shell Programming and Scripting 9 04-12-2008 11:53 PM
awk Shell Script error : "Syntax Error : `Split' unexpected Herry UNIX for Dummies Questions & Answers 2 03-17-2008 07:16 AM
I got error like...syntax error on line 1, teletype koti_rama UNIX for Advanced & Expert Users 2 07-07-2007 04:35 PM
for loop not working - syntax error at line 6: `end of file' unexpected debojyoty Shell Programming and Scripting 2 03-10-2006 11:45 AM
Syntax error.. livetaurean19 Shell Programming and Scripting 0 06-14-2005 01:23 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-18-2008
Registered User
 

Join Date: May 2008
Posts: 6
syntax error in while loop

Hi,

I have the following script (compile_mercury) and I get this error: I have no idea why...and I have written this script completely in linux (bash) and not in windows.

****************
./compile_mercury: line 136: syntax error near unexpected token `done'
./compile_mercury: line 136: `done'
****************

Here is the script. Line 136 is the second 'done' statement.

************
semi=2
while [ $semi -le 7 ]
semi2=0
while [ $semi2 -le 90 ]
e=1
while [ $e -le 12 ]
do
.....
....
e=`expr $e + 1`
done
semi2=`expr $semi2 + 10`
done
semi=`expr $semi + 1`
done
***************
Thanks
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 05-18-2008
era era is offline
Herder of Useless Cats
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,057
Without seeing the whole script, it's very hard to say. It's not uncommon for this error message to be caused by a quoting problem somewhere pretty far from the line indicated by the error message; if a misplaced quote hides a "fi" from the shell, it will still be looking for it when it gets to a "done" much later, and complain about the "done". (You seem to be missing a "do" after "while [ $semi2 -le 90 ]"; perhaps this is related.)

I hope you have indentation in your actual script to show the structure, especially if it's that long. You might want to use code tags when posting code snippets in the future.
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:10 AM.


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

Content Relevant URLs by vBSEO 3.2.0