| Author |
Syntax error at line 150 : `((' is not expected.
|
jaya kemmannu
Ranch Hand
Joined: Sep 23, 2011
Posts: 72
|
|
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
Joined: Apr 06, 2010
Posts: 3791
|
|
|
Try adding some additional spaces, so the (( and )) are separate from the contents.
|
 |
jaya kemmannu
Ranch Hand
Joined: Sep 23, 2011
Posts: 72
|
|
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
Joined: Jun 25, 2001
Posts: 14460
|
|
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.
|
Customer surveys are for companies who didn't pay proper attention to begin with.
|
 |
jaya kemmannu
Ranch Hand
Joined: Sep 23, 2011
Posts: 72
|
|
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
Joined: Jun 25, 2001
Posts: 14460
|
|
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
Joined: Sep 23, 2011
Posts: 72
|
|
Hi,
I got "/usr/bin/sh" for the command echo $SHELL. so which command it is ?
Regards,
Jaya
|
 |
Tim Holloway
Saloon Keeper
Joined: Jun 25, 2001
Posts: 14460
|
|
It's probably an alias. Try this:
|
 |
Anand Hariharan
Rancher
Joined: Aug 22, 2006
Posts: 252
|
|
The very first line of your script should read -
|
"Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away." -- Antoine de Saint-Exupery
|
 |
jaya kemmannu
Ranch Hand
Joined: Sep 23, 2011
Posts: 72
|
|
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
Joined: Jun 25, 2001
Posts: 14460
|
|
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
Joined: Aug 22, 2006
Posts: 252
|
|
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-
|
 |
 |
|
|
subject: Syntax error at line 150 : `((' is not expected.
|
|
|