Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Syntax error at line 150 : `((' is not expected.

 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

In my shell script i am getting below error. Can anyone help me to rectify this.

/./software/com/np/scripts/NP_Mediation.sh[113]: Syntax error at line 150 : `((' is not expected



thanks and regards,
JOY
 
Matthew Brown
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try adding some additional spaces, so the (( and )) are separate from the contents.
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hello,

I tried below things but got same error. The same script work fine in RHEL but not in HP-UX server.

for ((i=1; i<=$FTP_HOST_COUNT; i++))

for (( i=1; i<=$FTP_HOST_COUNT; i++ ))

for ( (i = 1; i <= $FTP_HOST_COUNT; i++ ) )

Regards,
Joy
 
Tim Holloway
Saloon Keeper
Posts: 18304
56
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The "((" expression evaluation syntax is a characteristic of the Linux bash shell. Other shells/shell implementations may interpret (no pun intended) things differently.

For the case illustrated, I'm not sure what having double-parentheses is supposed to accomplish, regardless.
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi Tim,

MY problem got resolved by using below for loop sytanx

for i in 1 2 3
do
// do the task
done

instead of

for ((i=1; i<=$FTP_HOST_COUNT; i++))

Thanks and regards.
Joy
 
Tim Holloway
Saloon Keeper
Posts: 18304
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, iteration over a range of integers is fairly uncommon in shell scripts. But the "((" notation would would in the bash shell. Other shells, such as the Korn Shell (which IBM likes to use) have different conventions. For ksh, it would be


You can generally tell what shell you're using by issuing the "echo $SHELL" command at the command prompt.
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I got "/usr/bin/sh" for the command echo $SHELL. so which command it is ?

Regards,
Jaya
 
Tim Holloway
Saloon Keeper
Posts: 18304
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's probably an alias. Try this:
 
Anand Hariharan
Rancher
Posts: 272
C++ Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The very first line of your script should read -
 
jaya kemmannu
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,


$ ls -l /usr/bin/sh
-r-xr-xr-x 2 bin bin 587360 Nov 14 2007 /usr/bin/sh


The very first line in the script used : #!/bin/sh

Regards,
Jaya
 
Tim Holloway
Saloon Keeper
Posts: 18304
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The technical name for this first line is "shebang" and its significance is that when the script is marked executable and invoked directly from the command line, whatever program named in that statement will be used to run the script.

I did a quick check to see what the "/usr/bin/sh" program in hp-ux is and discovered that apparently it is a modified Korn shell with changes made that supposedly make it more Posix-compatible.

So instead of using bash syntax, you need to be using ksh syntax. Either that or run the script under bash (if it's available).
 
Anand Hariharan
Rancher
Posts: 272
C++ Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jaya kemmannu wrote:
MY problem got resolved by using below for loop sytanx

for i in 1 2 3
do
// do the task
done

instead of

for ((i=1; i<=$FTP_HOST_COUNT; i++))


Try-
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic