-bash: syntax error near unexpected token `('


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting -bash: syntax error near unexpected token `('
# 1  
Old 07-29-2016
-bash: syntax error near unexpected token `('

// AIX 6.1

I am getting a syntax error below. Please advise what to be corrected. Smilie

Code:
runmqsc CERN.$(echo `hostname` | cut -d'.' -f1 | tr '[:lower:]' '[:upper:]').$(echo $environment | tr '[:lower:]' '[:upper:]') <<! | egrep -i '(FROM.NC.APPLIANCE)' | sort -u |awk '{print $2}' | cut -d '(' -f2 | cut -d ')' -f1 | while read line; do dig -x $line +short; done; dis qstatus(cern.ssreq.security) type(handle) all
!

Code:
-bash: syntax error near unexpected token `('


Last edited by RudiC; 07-29-2016 at 04:27 PM.. Reason: Changed HTML to CODE tags.
# 2  
Old 07-29-2016
Making lots of assumptions and having no idea why you have an empty here-document feeding data into a tr command that is also reading from a pipeline nor why you think you need a case insensitive search while using egrep on input that has already been converted to uppercase only by two preceding tr commands, you might want to try:

Code:
runmqsc "CERN.$(echo `hostname` | cut -d'.' -f1).$(echo "$environment")" |
    tr '[:lower:]' '[:upper:]' |
    egrep '(FROM.NC.APPLIANCE)' |
    sort -u |
    awk '{print $2}' |
    cut -d '(' -f2 | cut -d ')' -f1 |
    while read line
    do   dig -x "$line" +short
    done
dis 'qstatus(cern.ssreq.security)' 'type(handle)' all

This assumes that you don't want to convert tabs and sequences of one or more spaces and tabs in the expansion of $environment to single spaces and that the first character of the expansion of $environment is not a minus sign immediately after any leading spaces and tabs have been removed. I also assume that there are backslash escape sequences embedded in the expansion of $environment or you would have just used:
Code:
$envionment

instead of:
Code:
$(echo $environment)

and that you are using a version of bash on a system where echo expands backslash escapes by default.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Ubuntu

Syntax error near unexpected token `('

detect_mouse_mvt.sh /home/andy/bin/detect_mouse_mvt.sh: line 4: syntax error near unexpected token `(' /home/andy/bin/detect_mouse_mvt.sh: line 4: `fh = file('/dev/input/mice')' #!/bin/bash # # fh = file('/dev/input/mice') while True: fh.read(3) print 'Mouse... (15 Replies)
Discussion started by: drew77
15 Replies

2. 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

3. Shell Programming and Scripting

Trying to pass a password: bash: syntax error near unexpected token `('

howdy, so I'm make a plugin work for Nagios, and the commandline is: /usr/lib/nagios/plugins/check_mssql -H MySQLServerName -u MySqlAccountName -p MyPassword(#XXXXX -d MyDatabaseName it is barfing with: bash: syntax error near unexpected token `(' Thoughts? Do I have to wrap something... (2 Replies)
Discussion started by: rgouette
2 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 `('

What do I do here? #!/bin/bash payload=-1 AND 1=IF(21,BENCHMARK(5000000,MD5(CHAR(115,113,108,109,97,112))),0)# hash=`echo -n $payload md5sum tr -d 'n' sed 'ss-sg' md5sum tr -d 'n' sed 'ss-sg'` curl --data cs2=chronopay&cs1=$payload&cs3=$hash&transaction_type=rebill... (2 Replies)
Discussion started by: iiiiiiiiiii
2 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. UNIX for Advanced & Expert Users

syntax error near unexpected token '{

Hi, I am running the following script through cygwin and getting below mentioned error. ******************************************* #!/bin/sh # constants WORK_DIR="deploy" INFOFILE="deploy.info" INTROFILE="Intro.sh" CMGMT_PKG="com.kintana.cmgmt.deploy" DEPLOY_PREFIX="mitg" ... (2 Replies)
Discussion started by: MandyR
2 Replies

9. Shell Programming and Scripting

Syntax error near unexpected token `done'

Hi all, Here is a simple script that is working in one server and is giving a syntax error in other server. Can somebody help me ? #!/bin/bash # ftp files done < $file errors: I tried..with no success: if ; then (21 Replies)
Discussion started by: Lenora2009
21 Replies

10. 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
Login or Register to Ask a Question