Syntax error at line 14: `gw_user=' unexpected


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Syntax error at line 14: `gw_user=' unexpected
# 1  
Old 11-23-2011
Syntax error at line 14: `gw_user=' unexpected

Masters, i iam writing a script (dont have much experience in the process of learning) which handles file copy to multiple servers and users for deployment purpose. Below is the snippet.

When ever i run i get syntax error but it works fine on another machine. Please help me out.
Code:
if [ $# -eq 0 ]
then
echo -e " Please enter minimum 1 arguement seperated by space. \n Example: BASIC,IMM etc."
else
case "$1" in
ICP) echo -e "Welcome to ICP"
     
     gw_user=(icpct_gw) # arrays username
     gui_user=(icpct_ui)
     gw_host=(ston160)
     gui_host=(ston260)  # arrays hostname

     echo "Please enter where you want to sync?.. Example: For gateway enter GW, gui enter GUI and for entire ICP enter ALL"
     read x

        if [ "$x" == 'GW' ]
        then
        #echo "Successful"
        for (( i = 0 ; i <= 1 ; i++ ))
        do
        ssh ${gw_user[$i]}@${gw_host[$i]} mkdir DEPLOYTOOL/test
        done

        fi    
      
;;
*) echo -e "Please enter valid input. \n Example: BASIC,IMM etc."
;;
esac
fi

passed with valid arguement.
Code:
# ./1sync.sh ICP

o/p
Code:
# ./1sync.sh: line 25: syntax error near unexpected token `(('
# ./1sync.sh: line 25: `        for (( i = 0 ; i <= 1 ; i++ ))'

Executed with -x gives
Code:
sh -x ./1sync.sh ICP
./1sync.sh: syntax error at line 14: `gw_user=' unexpected

Please help me

code tags[/mod]

Last edited by Franklin52; 11-23-2011 at 03:29 AM.. Reason: Code tags
# 2  
Old 11-23-2011
Version of shell on the machine where it is failing is out of date, or you're not executing the script on the failing machine with the same shell. On the machine that is having the problem, what is the output of this command:

Code:
echo $SHELL

If it's not bash or ksh, then you're problem might be solved by adding one of these two lines as the very first (no blanks before it) line of the script:

Code:
#!/usr/bin/env bash
#!/usr/bin/env ksh

This should force the script to be interpreted by bash. You could also try ksh if bash doesn't seem to work.
# 3  
Old 11-23-2011
this is just a test script which creates a directory @ remote machine.

----------
output. --> this a valid o/p as ssh does not work from test machine
----------
Welcome to ICP
Please enter where you want to sync?.. Example: For gateway enter GW, gui enter GUI and for entire ICP enter ALL
GW
ssh: ston160: Name or service not known
usage: ssh [-1246AaCfgkMNnqsTtVvXxY] [-b bind_address] [-c cipher_spec]
[-D [bind_address:]port] [-e escape_char] [-F configfile]
[-i identity_file] [-L [bind_address:]port:host:hostport]
[-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R [bind_address:]port:host:hostport] [-S ctl_path]
[-w tunnel:tunnel] [user@]hostname [command]

--------------------------------------------------------------------------

but when i try to run @ my prod box which has ssh there it fails and my o/p is available @ 1st post.

my shell is bash.

where i need to use this?

#!/usr/bin/env bash
#!/usr/bin/env ksh
# 4  
Old 11-23-2011
Quote:
Originally Posted by ameyrk
where i need to use this?

#!/usr/bin/env bash
#!/usr/bin/env ksh
You need to put the bash line at the top of the script that you are attempting to run; the script that is giving you the message about unexpected ((.
# 5  
Old 11-23-2011
i did but it did not work .. :-( same error
./1sync.sh: line 26: syntax error near unexpected token `(('
./1sync.sh: line 26: ` for (( i = 0 ; i <= 1 ; i++ ))'
# 6  
Old 11-23-2011
Try replacing your for loop with this...
Code:
i=0
while [ $i -le 1 ]
do
  ssh ${gw_user[$i]}@${gw_host[$i]} mkdir DEPLOYTOOL/test
  let i=i+1
done

--ahamed
# 7  
Old 11-23-2011
It seems you have syntax problem for sure if you are executing the script in bash shell .

Please make sure that you are using bash shell for executing the script

PHP Code:
bash  1sync.sh ICP 
If this is not working please post here the exact script which you are executing .
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Sh: -c: line 0: syntax error near unexpected token `(' how to resolve this

Below query is not working for me. Please help me on this DATA EXCLUDE STATEMENT: TABLE:\"LIKE \'%\_HISTORY\'\", TABLE:\"LIKE \'%\_HIST\'\", TABLE:\"in \(select tname from tab where REGEXP_LIKE(TNAME,\'\_H$\'\))\", TABLE:\"LIKE \'%\_LOG\'\", TABLE:\"LIKE \'DW\_%\'\", TABLE:\"LIKE... (1 Reply)
Discussion started by: princy
1 Replies

2. Shell Programming and Scripting

Syntax error at line 24: `(' unexpected

Hi, I am getting an wired error.... the script is running fine when i run it manually... but the same when i try to run in nohup mode, i am getting error if Error: syntax error at line 24: `(' unexpected The above if is the 24th line!!! I dont understand the error... (4 Replies)
Discussion started by: Nithz
4 Replies

3. Shell Programming and Scripting

line 15: syntax error: unexpected end of file

Hi all, I am very new to programming and even newer to this forum as well, so I apologize if this should have been in the Newbie category, but... I am currently trying to figure out Shell Scripting and am running into problems early. Not having taken any kind of programming class, I am not even... (2 Replies)
Discussion started by: ccorder22
2 Replies

4. UNIX for Dummies Questions & Answers

syntax error at line 8: `(' unexpected

Hi I am having a shell script load_data.sh which calls /home/users/project/.profile. When am executing the script, am getting below error: $sh -x bin/load_data.sh null + . /home/users/project/.profile bin/load_data.sh: syntax error at line 8: `(' unexpected The line which is throwing... (1 Reply)
Discussion started by: brijesh.dixit
1 Replies

5. Shell Programming and Scripting

syntax error at line 28: `(' unexpected

hi can anyone pls look into this....shell script... Pls find the error below: > sh -n tmp tmp: syntax error at line 28: `(' unexpected isql -Usa -S$1 -P`grep $1 dbpassword|cut -d ":" -f3` -w2000 -b<<! set nocount on declare @i int declare @dbname char(6) declare @tmp int if... (10 Replies)
Discussion started by: rajashekar.y
10 Replies

6. UNIX Desktop Questions & Answers

line 3: syntax error near unexpected token `('

Hi All I've used UNIX in the past experimenting with commands through terminal but thats about it. Im now currently teaching myself "C". Using a book from the library, the first chapter asks you run and compile your program from a command-line prompt. As you will see the program is very simple,... (4 Replies)
Discussion started by: camzio
4 Replies

7. Shell Programming and Scripting

interface_file_ff.sh[99]: syntax error at line 1 : `)' unexpected

Hi, I tried to execute the following code but it showed the output mobile number : 35353425 corr plan id : 13-may-2008 corr target : 551 active_dt : 23414 no ident : IDD action name: A To get the subscriber number for the given mobile number and check if it is active and not... (1 Reply)
Discussion started by: geekforu
1 Replies

8. Solaris

syntax error at line 59: `end of file' unexpected

Hello... I'm trying to run the sshd script, but I keep geting the Syntax errot message . Here's the last few lines on the script. set nu in vi shows 58 lines, but I keep getting error referring to line 59. Any help is appreciated. Thanks, Remi else echo... (4 Replies)
Discussion started by: Remi
4 Replies

9. UNIX for Dummies Questions & Answers

syntax error at line 33: `elif` unexpected

#!/bin/sh echo "Choose option: e, d, l, t, p, or x." read option if test $option = e then echo "Filename?" read file if test ! -f $file then echo "No such file" else echo "Yes its a file" fi ... (4 Replies)
Discussion started by: hazy
4 Replies

10. Programming

sh: syntax error at line 1: `>' unexpected

I compiled C program under SUN OS sparcv9 ...I had a problem related to SIGBUS which has been resolved by adding an option to the CC compiler which is memory alignement option ..-memalign=1i as I remmber ...after running the program I got the below error please let me KNow more details what should... (2 Replies)
Discussion started by: atiato
2 Replies
Login or Register to Ask a Question