Urgent:- syntax error near unexpected token `done'


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Urgent:- syntax error near unexpected token `done'
# 1  
Old 06-25-2009
Bug Urgent:- syntax error near unexpected token `done'

hi,

i need to with making while loop logic working in shell program, i got syntax error

the following Code and Error details:

x=60
while [ ${x} -gt 0 ]
do
/usr/bin/php /home/egrdemo/public_html/pposh_new/cron-set.php
x=$((x-1))
sleep 1
done

/home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh: line 6: syntax error near unexpected token `done'
/home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh: line 6: `done'

Kindly help me Smilie
# 2  
Old 06-25-2009
x=`expr $x - 1`

use this one instead of x=$((x-1))
# 3  
Old 06-25-2009
Urgent:- syntax error near unexpected token `done' Reply to Thread

Quote:
Originally Posted by jayan_jay
x=`expr $x - 1`

use this one instead of x=$((x-1))

hi,

thanks for your quick reply

i have updated as per the code but the same syntax error came again

the following error:

/home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh: line 7: syntax error near unexpected token `done'
/home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh: line 7: `done'


Kindly help me....

Last edited by kannankrp; 06-25-2009 at 06:37 AM..
# 4  
Old 06-25-2009
Data Your code is correct

see the output which i got

Apps-Monitor [/home/osseng/Task] -bash-15:21:41$ cat 5secondrotatorscript.sh
x=60
while [ ${x} -gt 0 ]
do
/usr/bin/php /home/egrdemo/public_html/pposh_new/cron-set.php
x=$((x-1))
sleep 1
done

Apps-Monitor [/home/osseng/Task] -bash-15:21:43$ ./5secondrotatorscript.sh
Could not open input file: /home/egrdemo/public_html/pposh_new/cron-set.php
Could not open input file: /home/egrdemo/public_html/pposh_new/cron-set.php
Could not open input file: /home/egrdemo/public_html/pposh_new/cron-set.php

Apps-Monitor [/home/osseng/Task] -bash-15:21:47$ uname -a
Linux localhost.localdomain 2.6.15-1.2054_FC5 #1 Tue Mar 14 15:48:33 EST 2006 i686 i686 i386 GNU/Linux
# 5  
Old 06-25-2009
Bug Urgent:- syntax error near unexpected token `done' Reply to Thread

Quote:
Originally Posted by mphanikumars
see the output which i got

Apps-Monitor [/home/osseng/Task] -bash-15:21:41$ cat 5secondrotatorscript.sh
x=60
while [ ${x} -gt 0 ]
do
/usr/bin/php /home/egrdemo/public_html/pposh_new/cron-set.php
x=$((x-1))
sleep 1
done

Apps-Monitor [/home/osseng/Task] -bash-15:21:43$ ./5secondrotatorscript.sh
Could not open input file: /home/egrdemo/public_html/pposh_new/cron-set.php
Could not open input file: /home/egrdemo/public_html/pposh_new/cron-set.php
Could not open input file: /home/egrdemo/public_html/pposh_new/cron-set.php

Apps-Monitor [/home/osseng/Task] -bash-15:21:47$ uname -a
Linux localhost.localdomain 2.6.15-1.2054_FC5 #1 Tue Mar 14 15:48:33 EST 2006 i686 i686 i386 GNU/Linux
hi,

the code I have used in UNIX, this code is running good when it is executed in command prompt, but when I saved this file with .sh extension, this giving the below Error message. Please check and help me in this.

the following running command and output:

[admin2009@ip-208-109-22-128 ~]$ sh /home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh
/home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh: line 7: syntax error near unexpected token `done'
/home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh: line 7: `done'


kindly help meSmilie

Last edited by kannankrp; 06-25-2009 at 01:05 PM..
# 6  
Old 06-26-2009
I got your issue...

If you run script with "sh /home/egrdemo/public_html/pposh_new/5secondrotatorscript.sh"

sh --> will not understand --> x=$((x-1))
Please change this line to --> x=`expr $x - 1`

Good Luk
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Syntax error near unexpected token

Dears, While executing the below script im getting the error at line 30. Please let me know what changes to be done to fix this. test.sh: line 30: syntax error near unexpected token `done' test.sh: line 30: ` done ' #!/bin/sh # Rev. PA1 # author: eillops # date: 26-04-2018 # #... (1 Reply)
Discussion started by: Kamesh G
1 Replies

2. UNIX for Beginners Questions & Answers

Syntax error near unexpected token 'do'

Hello all, Please i have this command i used to zip different files in differents directory, but i have an error. Note that when i run the command in one directory it works fine. /X5/WORK/BGH/INV/REG/pdf/SEND/BGH12523/1/*.fo /X5/WORK/BGH/INV/REG/pdf/SEND/BGH24523/1/*.fo... (3 Replies)
Discussion started by: gillesi
3 Replies

3. How to Post in the The UNIX and Linux Forums

Syntax error near unexpected token `('

I have 2 files like a.txt and b.txt and the content is as below cat a.txt 810750125 117780 /BSCSQAT4A/bscsqat4a/lib/jar/wclt_common.jar 1803152428 13300 /BSCSQAT4A/bscsqat4a/lib/jar/WFMSSupportTool.jar 2663502779 67049 /BSCSQAT4A/bscsqat4a/lib/jar/wma.jar 687942896 665272... (1 Reply)
Discussion started by: ranabhavish
1 Replies

4. Shell Programming and Scripting

Syntax error near unexpected token

Hi all, I have a simple script that doesn't work somehow. I can't seem to be spotting the cause of the malfunction. count=$((1)) for item in `cat test1.txt` printf %s `sed -n $((count))p test2.txt` > test3.txt count=$((count+1)) do something done I get ; ./why.sh: line 3:... (14 Replies)
Discussion started by: y33t
14 Replies

5. Shell Programming and Scripting

Syntax error near unexpected token `|'

Hi All; I try to write a bash code and I am using command substitution. My code is like: #!/bin/bash IP="10.0.0.1 10.0.0.2" PORT="22 80" USERNAME="admin" SCRIPT_HOST="adminHost" HOME_DIR=/home/admin SCRIPT_DIR=$HOME_DIR/scripts script="sudo /my_remote_script.sh" SSH="/usr/bin/ssh... (7 Replies)
Discussion started by: Meacham12
7 Replies

6. Shell Programming and Scripting

syntax error near unexpected token `='

Hi all, This is a script which converts hex to bin. However am finding an error while executing syntax error near unexpected token `=' `($hexfile, $binfile) = @ARGV;' I am running using ./fil.pl <hexfile> <binfile> ################################################### # # this script... (3 Replies)
Discussion started by: jaango123
3 Replies

7. UNIX for Dummies Questions & Answers

Syntax error near unexpected token

hi! just want to seek help on this error: syntax error near unexpected token 'do this is my script # !/bin/sh # for y in 27 25 do exemmlmx -c "ZEEI;" -n XRT$y >> blah done what can be wrong? thanks! (6 Replies)
Discussion started by: engr.jay
6 Replies

8. Shell Programming and Scripting

Syntax error near unexpected token `('

Guys , This is an output of my script errored out for "Syntax error near unexpected token `(' " Can someone tell me whats wrong with my script. Below is my original script pasted. #!/bin/bash Script Creation Date 01/21/2010 Author baraghun ... (7 Replies)
Discussion started by: raghunsi
7 Replies

9. UNIX for Advanced & Expert Users

Syntax error near unexpected token

Hi, When I run the below shell script I'm getting the error " syntax error near unexpected token `" Script: REM :: File Name : Refresh_OTL.bat REM :: Parameters : %1 - Region REM :: : %2 - Cube Type REM :: : REM :: Notes : REM ============================== set ENVIRONMENT... (2 Replies)
Discussion started by: tomailraj
2 Replies

10. Shell Programming and Scripting

sh syntax error unexpected token done

I'm getting the following error: line 21: syntax error near unexpected token `done` line 21: `done` and I haven't been able to figure out why. Here is my code #!/bin/sh if ; then echo 'Usage: rename getexp/replStr ' exit 0 fi arg = $1 shift while ; do (5 Replies)
Discussion started by: NullPointer
5 Replies
Login or Register to Ask a Question