• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

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

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try adding some additional spaces, so the (( and )) are separate from the contents.
 
jaya kemmannu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 28660
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28660
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28660
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's probably an alias. Try this:
 
Rancher
Posts: 280
VI Editor C++ Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The very first line of your script should read -
 
jaya kemmannu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 28660
211
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 280
VI Editor C++ Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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-
 
reply
    Bookmark Topic Watch Topic
  • New Topic