Line 1 syntax error unexpected word expecting

Problem in short - In Linux, whenever we get the following error "Syntax error: word unexpected (expecting ")")", what does it generally mean? Problem in details - I have been t...

That’s an error reported by the Almquist shell or any of its derivatives like Dash (and Dash happened to be the default implementation of /bin/sh on Ubuntu 10.04 (Lucid Lynx)) when a word is found while parsing the syntax of a script where a ) is expected instead, for instance like in this case statement:

dash -c 'case a in b c) :; esac'

dash: 1: Syntax error: word unexpected (expecting ")")

That’s because after b , the only thing that is expected after is ), (though actually | would also be allowed) so that c word is unexpected.

dash -c 'myfunc( something'

dash: 1: Syntax error: word unexpected (expecting ")")

One case where that can happen is if the script has been written on or transferred through a Microsoft OS where text line endings are CRLF instead of just LF.

A

case a in b) cmd1;;
          c) cmd2
esac

script written on MS-DOS would appear as:

case a in b) cmd1;;<CR>
          c) cmd2<CR>
esac<CR>

on Unix and that c would be an extra word after the <CR> word.

Here that’s unlikely as your error reports the problem being on the first line of the script and most scripts start with the #! /path/to/interpreter shebang line.

Another possibility is that that script you’re trying to run has been written on the assumption that sh was bash and uses constructs that are not portable to other sh implementations.

Since you’re using an outdated and no longer maintained OS, it’s also possible that you’re running into a bug in that version of Dash. You could run dpkg-reconfigure dash and tell the system not to use Dash for sh (but Bash instead) to see if that helps.

Again, it is unlikely to be on the first line.

What sounds more likely is that that qmake file is not a script, but a binary executable that is not recognised as such by the system, for instance because it is of a binary format for the wrong architecture or it has been corrupted in transfer.

In that case, when the system fails to recognise it as a native executable, the invoking application would try to run sh on it as if it was a shell script, and the presence of a ( character in the file could cause Dash to fail with such an error.

On my system:

dash /bin/touch

/bin/touch: 1: /bin/touch: Syntax error: word unexpected (expecting ")")

And if you look at the content of /bin/touch as if it were a script, you see:

^?ELF^B^A^A^@^@^@^@^@^@^@^@^@^B^@>^@^A^@^@^@5&@^@^@^@^@^@@^@^@^@^@^@^@^@(ô^@^@...

I have a bash script:

#!/bin/bash

VAR1="var1"
VAR2="var2"
VAR3="var3"

cat ${VAR1} 
    <(echo -e '<something>')                        # <--------- here's the error
    ${VAR2}/file123.txt 
    <(echo -e '</something>n<something2>') 
    ${VAR3}/file456.txt 
    <(echo -e '</something2>')

When I run it: sh my_script.sh, I get the error:

 my_script.sh: 9: Syntax error: "(" unexpected (expecting word)

update:

bash isn’t found, «/bin/bash» doesn’t exist. neither bash does.

asked Nov 22, 2016 at 10:59

Kurama's user avatar

KuramaKurama

1231 gold badge1 silver badge5 bronze badges

8

Try :

chmod 755 "my_script.sh"

Then run it simply like this

my_script.sh

The #!/bin/bash line at the beginning is used to tell your system which shell you should run the script with. I think you are overiding this by executing it with sh my_script.sh. You could also explicitly write /bin/bash my_script.sh. Also if you have some bash specific syntax in your script, you should consider changing the extension to .bash to be more explicit.


EDIT

You don’t seem to have bash on your FreeBSD distro (the default shell on FreeBSD appears to be tcsh). You can find here a tutorial to install bash on FreeBSD. The solution I provided should then work properly. Best of luck.

answered Nov 22, 2016 at 13:25

Valentin B.'s user avatar

Valentin B.Valentin B.

7655 silver badges18 bronze badges

6

Obviously from the she-bang, that script is intended to be run by bash not sh (even though the syntax looks more like zsh syntax because of the unquoted variables).

You’ll want to run it with bash or zsh. If those shells are not available, you can install them or alternatively, translate that script to sh syntax which should be straightforward here.

The sh language (both Bourne or POSIX) has no <(...) operator. That comes from ksh and is supported by bash and zsh as well. echo -e is non-standard and even with bash and ksh only works in some environments.

The standard sh equivalent would be:

var1="var1"
var2="var2"
var3="var3"

cat < "$var1" || exit
printf '<something>n' || exit
cat < "$var2/file123.txt" || exit
printf '</something>n<something2>n' || exit
cat < "$var3//file456.txt" || exit
print '</something2>n'

answered Nov 22, 2016 at 17:08

Stéphane Chazelas's user avatar

Stéphane ChazelasStéphane Chazelas

498k90 gold badges967 silver badges1445 bronze badges

I am trying to install Anaconda3 in ubuntu14.04 like this:

seyyedhossein@hossein:~$ sh Anaconda3-4.2.0-Linux-x86_64.sh 

and I get :

Anaconda3-4.2.0-Linux-x86_64.sh: 16: Anaconda3-4.2.0-Linux-x86_64.sh: 0: not found
Anaconda3-4.2.0-Linux-x86_64.sh: 61: Anaconda3-4.2.0-Linux-x86_64.sh: 0: not found
Anaconda3-4.2.0-Linux-x86_64.sh: 75: Anaconda3-4.2.0-Linux-x86_64.sh: Syntax error: word unexpected (expecting ")")

what is the problem here?
I had installed it on another account (which was initially downloaded from) successfully. but when I logged in to my new account, it just wont run!

Update:
The output of the cat command :

#!/bin/bash
# Copyright (c) 2012-2016 Continuum Analytics, Inc.
# All rights reserved.
#
# Name: Anaconda3
# Version: 4.2.0
# Packages: 195
# PLAT:  linux-64
# DESCR: 4.1.1-889-g7ce9b7f
# BYTES: 478051940
# LINES: 558
# MD5:   1ee1f5cb1d92a230e59cc5fce0dca5ba

unset LD_LIBRARY_PATH
echo "$0" | grep '.sh$' >/dev/null
if (( $? )); then
    echo 'Please run using "bash" or "sh", but not "." or "source"' >&2
    return 1
fi

THIS_DIR=$(cd $(dirname $0); pwd)
THIS_FILE=$(basename $0)
THIS_PATH="$THIS_DIR/$THIS_FILE"
PREFIX=$HOME/anaconda3
BATCH=0
FORCE=0

while getopts "bfhp:" x; do
    case "$x" in
        h)
            echo "usage: $0 [options]

Installs Anaconda3 4.2.0

    -b           run install in batch mode (without manual intervention),
                 it is expected the license terms are agreed upon
    -f           no error if install prefix already exists (force)
    -h           print this help message and exit
    -p PREFIX    install prefix, defaults to $PREFIX
"
            exit 2
            ;;
        b)
            BATCH=1
            ;;
        f)
            FORCE=1
            ;;
        p)
            PREFIX="$OPTARG"
            ;;
        ?)
            echo "Error: did not recognize option, please try -h"
            exit 1
            ;;
    esac
done

# verify the size of the installer
wc -c "$THIS_PATH" | grep 478051940 >/dev/null
if (( $? )); then
    echo "ERROR: size of $THIS_FILE should be 478051940 bytes" >&2
    exit 1
fi

if [[ $BATCH == 0 ]] # interactive mode
then
    if [[ `uname -m` != 'x86_64' ]]; then
        echo -n "WARNING:
    Your operating system appears not to be 64-bit, but you are trying to
    install a 64-bit version of Anaconda3.
    Are sure you want to continue the installation? [yes|no]
[no] >>> "
        read ans
        if [[ ($ans != "yes") && ($ans != "Yes") && ($ans != "YES") &&
              ($ans != "y") && ($ans != "Y") ]]

asked Oct 29, 2016 at 18:29

Hossein's user avatar

HosseinHossein

1,5914 gold badges19 silver badges35 bronze badges

1

The problem is with the script: though it claims in its own documentation that it can be run by sh, i.e. by any standard POSIX shell, it actually requires bash.

The construct (( $? )) is not valid POSIX sh, nor is ($ans != "yes") when $ans is empty. They are hardly valid in bash either (TBH, this is the first time in 20yrs I see the idiom (( $? ))) but apparently bash lets it pass.

Solution: run using bash: bash Anaconda3-4.2.0-Linux-x86_64.sh

answered Oct 29, 2016 at 19:31

zwets's user avatar

zwetszwets

11.5k2 gold badges31 silver badges44 bronze badges

The sh command that you’re giving assumes that the .sh file is in your home directory. It may be located elsewhere, in which case you have to give it a pathname to where the file is located.

Example: if the file Anaconda3-4.2.0-Linux-x86_64.sh is located on your Desktop, you can:

cd ~/Desktop
bash Anaconda3-4.2.0-Linux-x86_64.sh

or

bash ~/Desktop/Anaconda3-4.2.0-Linux-x86_64.sh

If that doesn’t solve your problem, please edit your question to include the output of:

cat Anaconda3-4.2.0-Linux-x86_64.sh | head -n 76

answered Oct 29, 2016 at 18:35

heynnema's user avatar

heynnemaheynnema

66.1k13 gold badges115 silver badges170 bronze badges

5

I used bash instead of sh, and the script ran just fine!
it seems sh was not meant to be used with this one!

answered Oct 29, 2016 at 19:24

Hossein's user avatar

HosseinHossein

1,5914 gold badges19 silver badges35 bronze badges

  • Home
  • Forum
  • TeamSpeak 3 Technical Discussions [EN/DE]
  • Server Support
  • Linux / FreeBSD
  • [Not possible] line 1: syntax error: unexpected «(«

  1. June 19th, 2010, 01:01 PM


    #1

    line 1: syntax error: unexpected «(»

    Hi there!
    I’m trying to run the server on an RT-N16 router with tomato firmware on it.
    It runs busybox, and i think it has the resources to run a small ts3 server on it, but when i try to start it, i get this message:
    ./ts3server_linux_x86: line 1: syntax error: unexpected «(«
    Can anyone tell me ALL the needed packages to run the server, or help me anyway?
    Thanks in advance


  2. June 19th, 2010, 02:26 PM


    #2

    /bin/sh links to a shell thats not compatible I would guess. Do you have a bash installed? But I would suspect that you cannot run the binary on your router, because I think it doesn’t have a x86er architecture…


  3. June 19th, 2010, 02:44 PM


    #3

    I have bash installed, i can run sh scripts normally, so that’s not the problem.
    About the architecture: yeah, maybe that’s the problem. I don’t know.
    Here’s a link for the firmware if that helps:
    http://www.linksysinfo.org/forums/sh…ad.php?t=63587

    The only thing i know is that i installed mc and things like that with ipkg-opt, and they work great. (ofc i have samba, ftp and web servers too)
    I think they were compiled specially for the router, but i can’t compile ts3 if i don’t have the source, and even if i had i’d have to rewrite some things, am i right?


  4. June 19th, 2010, 02:55 PM


    #4

    Quote Originally Posted by Bordafan
    View Post

    Seems to be some kind of MIPS.

    Quote Originally Posted by Bordafan
    View Post

    The only thing i know is that i installed mc and things like that with ipkg-opt, and they work great. (ofc i have samba, ftp and web servers too)
    I think they were compiled specially for the router, but i can’t compile ts3 if i don’t have the source, and even if i had i’d have to rewrite some things, am i right?

    Exactly. And I don’t think that there will be ARM or MIPS versions during beta…


  5. June 19th, 2010, 03:19 PM


    #5

    I don’t even think there will be MIPS version when it’s finally released
    Anyway: thanks for the help

    Topic can be closed.


  6. September 1st, 2011, 12:55 AM


    #6

    New install — Syntax error unexpected «(»

    HI,

    im installing ts3 on Ubuntu 10 for the first time, i following this guide

    I used the RC1 x86 linux version (im assuming thats the most recent).

    All went to plan until i went to start the server at the end, and this is what i got

    Code:

    [email protected]:~$ /etc/init.d/teamspeak start
    [sudo] password for me:
    Starting the TeamSpeak 3 server
    TeamSpeak 3 server started, for details please view the log file
    [email protected]:~$ ./ts3server_linux_x86: 1: Syntax error: "(" unexpected

    i google this for hours and found nothing that could help, also there is no ‘logs’ directory created so no log file either.

    can anyone advise what else i could try?

    Last edited by florian_fr40; January 15th, 2012 at 09:19 AM.


  7. September 1st, 2011, 01:52 AM


    #7

    Hello

    Quote Originally Posted by ukrai

    I used the RC1 x86 linux version (im assuming thats the most recent).

    Hum no, go to the download page to get the last (and final) version : http://www.teamspeak.com/?page=downloads

    About your syntax error message, maybe this thread can help you :
    http://forum.teamspeak.com/showthrea…router-(linux)
    Search function


  8. September 1st, 2011, 03:09 AM


    #8

    reinstalled with the site downloaded version, same error.

    ive seen that topic before but doesnt really help me unfortunately.

    —— Post Merged ——

    all good, reinstalled from scratch and running fine now, probably a typo somewhere, thanks for your help!

    Last edited by florian_fr40; September 1st, 2011 at 08:44 AM.


  9. December 15th, 2011, 08:38 PM


    #9

    Talking TS3 server doest start

    hey it doesnt wanna start at al XD on my synology ds2011jj

    here is the error

    DiskStation> sh ts3server_startscript.sh start
    BusyBox v1.16.1 (2011-11-26 14:58:46 CST) multi-call binary.

    Usage: readlink FILE

    Display the value of a symlink

    Starting the TeamSpeak 3 server
    ./ts3server_linux_x86: line 1: syntax error: unexpected «(«
    TeamSpeak 3 server started, for details please view the log file

    theres No log file and the server did not start.
    any way of fixing this?
    thanks in advance!

    *** Thread Merged ***

    Last edited by florian_fr40; December 16th, 2011 at 08:54 AM.


  10. January 15th, 2012, 09:10 AM


    #10

    Encountering Same issue

    I’m running Ubuntu Server 10.10 64-bit.

    Fresh install using the above guide. Except pulling the latest file from your cache servers.

    I’ve tried starting it from the start script and get that error. I also get if if I try:

    sudo -u teamspeak ./ts3server_startscript.sh start

    or

    sudo -u teamspeak ./ts3server_startscript.sh restart

    I have also tried to run the EXE directly from the ts3 install directory:

    sudo -u teamspeak ./ts3server_linux_amd start

    All 3 attempts end ifn the same results.

    Don’t know what else to try. I’m going to go to bed now and hope for an answer by morning.

    — Kenbo666 out.


  11. April 6th, 2015, 02:49 PM


    #11

    Syntax error: word unexpected (expecting «)»)

    So I’m trying to host a server on my raspbery pi,
    Os: raspbian wheezy.
    I think its a raspberry pi 2.

    When I try : ./ts3server_startscript.sh start
    to start the server I get the error
    «
    Starting the TeamSpeak 3 server
    ./ts3server_linux_x86: 1: ./ts3server_linux_x86: Syntax error: word unexpected (expecting «)»)
    TeamSpeak 3 server could not start
    «

    I’m not to good with linux so I need some clear instructions.

    Last edited by dante696; April 6th, 2015 at 04:11 PM.

    Reason: merged


  12. April 6th, 2015, 03:04 PM


    #12

    Quote Originally Posted by MrPeace
    View Post

    So I’m trying to host a server on my raspbery pi,

    I’m not to good with linux so I need some clear instructions.

    Short and clear: It’s not supported yet.
    Details in this thread, you can start reading from post #121 and #123:
    http://forum.teamspeak.com/showthrea…085#post395085

    And this post has the same issue:
    http://forum.teamspeak.com/showthrea…180#post405180


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 6

    Last Post: April 30th, 2012, 03:05 PM

  2. Replies: 6

    Last Post: February 24th, 2012, 07:22 PM

  3. Replies: 0

    Last Post: December 23rd, 2009, 09:49 PM

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
  • BB code is On
  • Smilies are On
  • [IMG] code is Off
  • [VIDEO] code is Off
  • HTML code is Off

Forum Rules

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Unexpected «(» (expecting «}»)

Hi all,
I run the script runvdr from the package runvdr-extreme for many years without any problem (I’m not allowed to post links, but it should be easy to find). Now I tried to run it from within LibreElec which gives me the following error unexpected «(» (expecting «}»). The corresponding line… (12 Replies)

Discussion started by: ACorner

2. Shell Programming and Scripting

Error: «Syntax error; unexpected end of file»

Hello all,

I am running a script to generate a report and mail it to an email address.
When I am trying to validate whether the file is a 0 kb file, I am getting the below error.
Error: «Syntax error; unexpected end of file»

Any suggestions please?

Code:

#!/bin/sh
…. (1 Reply)

Discussion started by: Pradeep_Raj

4. Shell Programming and Scripting

Error»syntax error at line 15: `end of file’ unexpected»

While i m running below code, it is giving me the error»syntax error at line 15: `end of file’ unexpected».

Pls let me know what is wrong here..i tried many ways, but no luck

dbSID=»SWQE»
usrname=»apps»
password=»Wrgthrk3″
count=0
while
do
sqlplus $usrname/$password@$dbSID… (5 Replies)

Discussion started by: millan

5. Shell Programming and Scripting

Help with FTP Script which is causing «syntax error: unexpected end of file» Error

Hi All,

Please hav a look at the below peice of script and let me know if there are any syntax errors.

i found that the below peice of Script is causing issue. when i use SFTP its working fine, but there is a demand to use FTP only. please find below code and explain if anything is wrong… (1 Reply)

Discussion started by: mahi_mayu069

6. Shell Programming and Scripting

Help with error «syntax error: unexpected end of file»

Hi Techies,

can anyone please debug the following Script and let me know what is going wrong here.

im getting the following error

#!/usr/bin/bash
# ##############################################################################################
#
# Variables
#
#… (2 Replies)

Discussion started by: mahi_mayu069

7. Shell Programming and Scripting

Syntax error near unexpected token `»Hit <ENTER> to continue:»‘

the below code will search attr string inside makefile under the modelno on given path.

echo «Enter model no for searching string inside makefile»
read inputs2
#find /pools/home_unix/sapte/work/models/model/$inputs2 -name «makefile» | xargs grep «attr» ;
#;;I am getting below error…. (7 Replies)

Discussion started by: lathigara

8. Shell Programming and Scripting

Bash (Ubuntu server): Syntax error: «|» unexpected in While-loop

Hello forum,

I hope my problem is easy to solve for someone in here!

My main task is to copy a large amount of imap-accounts from one server to another. There is a tool (Perl) called imapsync which does the job exellent. Unfortunately I’m only able to run it on one account at a time.

After… (3 Replies)

Discussion started by: primaxx

9. Solaris

«syntax error near unexpected token `fi’ «

one of my script as follows

HOME=/apps/logs
mv $HOME/cron.log $HOME/cron.log.`date +%Y-%m-%d`
touch $HOME/cron.log
fi

i am getting error as follows

on the last line we are getting …

«syntax error near unexpected token `fi’ »

please suggest…. (4 Replies)

Discussion started by: GIC1986

10. Shell Programming and Scripting

«syntax error at line 21 :’done’ unexpected.» error message»

I am trying to run the script bellow but its given me «syntax error at line 20 :’done’ unexpected.» error message»
can someone check to see if the script is ok? and correct me pls.
Today is my first day with scripting.
Gurus should pls help out

#!/bin/ksh
# Purpose: Check to see if file… (3 Replies)

Discussion started by: ibroxy

Понравилась статья? Поделить с друзьями:

Читайте также:

  • Line 0 parsing error cannot read properties of undefined reading map
  • Linde t20 коды ошибок
  • Linalgerror schur decomposition solver error
  • Limit in subquery mysql error
  • Limit in sql syntax error

  • 0 0 голоса
    Рейтинг статьи
    Подписаться
    Уведомить о
    guest

    0 комментариев
    Старые
    Новые Популярные
    Межтекстовые Отзывы
    Посмотреть все комментарии