Bash For Syntax Error
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta bash syntax error near unexpected token done' Discuss the workings and policies of this site About Us Learn more
Bash Syntax Error Near Unexpected Token Else'
about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & bash syntax error near unexpected token fi' Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. bash syntax error invalid arithmetic operator Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the top Shell script fails: Syntax error: “(” unexpected up vote 31 down vote favorite 7 I've been working on a script that automates setting up a development environment
Bash Syntax Error Near Unexpected Token Then'
for Raspberry Pi development (step by step details that work are here). The script is linked in that article but convenience you can find it here also. Now when run this script install and sets up the environment without error but you have to enter your sudo password more than once due to sudo's time-out value by default. So I started experimenting by removing all the sudo lines and running the whole script via sudo at the command line like so: kemra102@ubuntuvm:~$ sudo ./pi_dev_env_install.sh This works fine as expected and gets most of the way through until this point: ./pi_dev_env_install: 68: ./pi_dev_env_install.sh: Syntax error: "(" unexpected Now this line worked fine previously when not running the whole script with sudo. There is nothing about this line running as sudo that should stop it working to my knowledge, does anyone have any ideas? bash shell ubuntu shell-script share|improve this question edited Aug 18 '12 at 12:08 Gilles 369k666681119 asked Aug 18 '12 at 11:37 kemra102 4681613 The shebang is really in line 9? Due to Ub
Syntax error: "(" unexpected stigalaJuly 12th, 2007, 09:33 AMHi, I'm trying to run a script on ubuntu 7.04; stig@stig-laptop:~/mosesdecoder$ ./regenerate-makefiles.sh ./regenerate-makefiles.sh: 13: Syntax error: "(" unexpected but then I get the syntax error. bash syntax error near unexpected token do' Below is the first lines in the script, line 13 in red. #!/bin/sh bash syntax error near unexpected token newline' # NOTE: # Versions 1.9 (or higher) of aclocal and automake are required. # For Mac OSX users: # Standard distribution
Bash Syntax Error Unexpected End Of File
usually includes versions 1.6. # Get versions 1.9 or higher # Set the following variable to the correct paths #ACLOCAL="/path/to/aclocal-1.9" #AUTOMAKE="/path/to/automake-1.9" function die () { echo "$@" >&2 exit 1 } ... I already http://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected have automake (GNU automake 1.9.6) and aclocal (GNU automake 1.9.6). Setting the paths is only for Mac OSX users, so I didn't try to set any of those paths. Anyone can explain this? Thanks for any help, Stig Rui PaisJuly 12th, 2007, 10:01 AMHi. the (inexistent) problem is the 1st line in combination with Ubuntu. When you run it using ./ it will use the shell you mention https://ubuntuforums.org/archive/index.php/t-499045.html on first line, in your case: #!/bin/sh if you do a ls -l /bin/sh you will see that it's just a link to dash. Ubuntu, since Edgy, replaced old sh with dash, creating a series of incompatibilities in a lot of scripts... So, either you run: bash regenerate-makefiles.sh or replace first line with: #!/bin/bash (or even remove the 1st line and environment will call it with bash) or (losing generality) adapt it for dash: remove the keyword function: die() { ... } hth stigalaJuly 12th, 2007, 10:55 AMThanks a lot, Rui! I used bash regenerate-makefiles.sh and the script ran perfectly. I guess I'll have to read up on dash, bash and sh to understand the difference between the different shells. Stig Rui PaisJuly 12th, 2007, 11:16 AMNo prob :) sh and bash has more or less the same syntax, so usually no problem came from there... but dash is much more different. it's suppose to be much lighter and faster then bash, being that the reason why they choose it by Edgy days. A lot of people had problem, specially with custom scripts. I still have to manually edit some files for use plugins on TeXmacs editor, and they are the offici
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn http://stackoverflow.com/questions/25222259/i-am-getting-error-array-sh-3-array-sh-syntax-error-unexpected more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up I am getting error “array.sh: 3: array.sh: Syntax error: ”(“ unexpected” up vote 3 down vote favorite 2 I have written the following code: #!/bin/bash syntax error #Simple array array=(1 2 3 4 5) echo ${array[*]} And I am getting error: array.sh: 3: array.sh: Syntax error: "(" unexpected From what I came to know from Google, that this might be due to the fact that Ubuntu is now not taking "#!/bin/bash" by default... but then again I added the line but the error is still coming. Also I have tried by executing bash array.sh but no luck! It prints blank. My Ubuntu version bash syntax error is: Ubuntu 14.04 arrays bash shell ubuntu share|improve this question edited Aug 9 '14 at 19:46 asked Aug 9 '14 at 19:29 Mistu4u 1,46662352 sh array.sh will generate that error because ordinary bourne shells, such as dash, do not understand arrays. bash array.sh should work fine. I tested your script and, under bash, it works for me. –John1024 Aug 9 '14 at 19:43 @John1024, bash array.sh prints blank in my case. –Mistu4u Aug 9 '14 at 19:45 What does echo $BASH_VERSION say? You may have an old version of bash. –Ned Deily Aug 9 '14 at 19:46 @NedDeily, 4.3.8(1)-release –Mistu4u Aug 9 '14 at 19:47 1 Add set -x after the shebang line. –Ned Deily Aug 9 '14 at 19:57 | show 5 more comments 3 Answers 3 active oldest votes up vote 9 down vote accepted Given that script: #!/bin/bash #Simple array array=(1 2 3 4 5) echo ${array[*]} and assuming: It's in a file in your current directory named array.sh; You've done chmod +x array.sh; You have a sufficiently new version of bash installed in /bin/bash (you report that you have 4.3.8, which is certainly new enough); and You execute it correctly then that should work without any problem. If you execute the script by typing ./array.sh the system will pay attention to