if its "#!/bin/sh" then its most likely the Bourne shell. if you put #!/bin/bash it will run with bash, if you put #!/bin/sh it will run with dash, unless you changed /bin/sh link from dash to bash (or other) reality1011June 15th, current community blog chat Super User Meta Super User your communities Sign up or log in to customize your list. And anyway, if you can't solve the problem with the information in this thread, ask a new question with the full content of the script and copy-paste the full error message(s). his comment is here
That will be true if even if the default login shell for that user is bash –Eric Renouf Jan 7 at 15:26 That was the part in which I EDIT: Because bash is a superset of sh, any sh script (including bash scripts that masquerade as sh) should still run when executed by bash. What are the holes on the sides of a computer case frame for? So I started experimenting by removing all the sudo lines and running the whole script via sudo at the command line like so: [email protected]:~$ sudo ./pi_dev_env_install.sh This works fine as expected
share|improve this answer answered Aug 18 '12 at 12:08 Gilles 369k666681119 1 Thanks clearly a gap in my knowledge, I don't script much so wasn't aware of that! WeyOhJune 11th, 2008, 08:39 PMWhat if my first line says: #!/bin/bash? period!
Because it didn't see an if, it doesn't know what to do when it sees then. (Actually, it knows exactly what to do: print a syntax error message.) ... Consider the following script, written with a Windows® text editor (^M is a symbolic representation of the CR carriage return character!): #!/bin/bash^M ^M echo "Hello world"^M ... foo=$(< inputfile) printf "DEBUG: foo is |%q|\n" "$foo" >&2 # exposes whitespace (such as CRs, see below) and non-printing characters Use shell debug output There are two useful debug outputs for Syntax Error ( Unexpected Bash Array So why does Ubuntu have to be different?
Can I use an HSA as investment vehicle by overcontributing temporarily? Shell Script Syntax Error ( Unexpected Some sh interpreters support arrays, only ksh88 (not ported to Linux AFAIK) and some older pdksh variants would support a[index]=value and not a=(x y). Here are the results: dpkg -S /bin/bash bash: /bin/bash Since bash is acually a link to dash, I'm not sure what this is telling me. Grab a bash binary of the same version from somewhere and manually install it.
Browse other questions tagged bash bash-scripting . Ksh Syntax Error Unexpected The difference lies in the use of the CR (Carriage Return) and LF (Line Feed) characters. bash shell-script array share|improve this question edited Jan 7 at 23:36 Gilles 369k666681119 asked Jan 7 at 14:42 IGGt 398213 Did you copy-pasted the script between the two server? Executing sudo sh ./sonar.sh console.
I do know that /bin/bash is a symbolic link to /bin/dash at the moment. Let's see the xtrace output: + '[' bar baz = test ']' And now you see that it's ("bar" and "baz") recognized as two separate words (which you would have realized Bash End Of File This is often incorrect, as we have seen. Expr Syntax Error In Shell Script Nithz View Public Profile Find all posts by Nithz #4 06-05-2012 gary_w Registered User Join Date: Oct 2010 Last Activity: 28 September 2016, 2:16 PM EDT Posts: 446
Something else might be broken, because .bashrc tries to execute when I log in and it crashes when it comes to the first command that is unique to bash (instead of this content 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 sh run_all_verification.sh? Why? How To Check Syntax Error In Shell Script
but dash is much more different. Remember that sh run_verification.sh has the same bash vs sh issue that you originally saw, and that it will look for run_verification.sh in the current working directory and not necessarily the To do this, add a "-x" to the first line of your script, like this: #!/bin/bash -x Now, when you run your script, bash will display each line (with substitutions performed) http://onlinetvsoftware.net/syntax-error/bash-script-expr-syntax-error.php Can filling up a 75 gallon water heater tank without opening a faucet cause damage?
You can easily confirm this is with a simple example: # #!/bin/bash offfset=(`ls`) echo $offset Running this script with sudo will raise a syntax error in recent versions of Ubuntu and Intuition behind Harmonic Analysis in Analytic Number Theory Finding a file starting with '-' dash Now I know my ABCs, won't you come and golf with me? They are especially bad when present in the shebang/interpreter specified with #! Line 1: Syntax Error: Unexpected Word (expecting ")") How to make different social classes look quite different?
So even if the script successfully started at some point in your testing, it would have aborted once line 68 was reached. share|improve this answer answered Aug 26 '14 at 0:34 R J 29112 add a comment| You must log in to answer this question. I had the wrong file name –Adam_G Mar 26 '15 at 20:12 You can give yourself permission to execute your file with chmod +x yourfile. check over here All rights reserved.
What's the difference? dwhitney67August 2nd, 2008, 06:28 AMThat's just masking the problem, so I think it's a bad idea. The second type displays the value of a variable (or variables) used in a calculation or test. Was running wrong arch executable.
Please delete my previous version and post this one instead. Any thoughts? #!/bin/bash if [ `date +%H` -lt 11 ] ; then exit 0; fi if [ `date +%H` -gt 14 ] ; then if[ `date +%H` -lt 20 ] ; Symbolic comparison of recursive functions Is the standard Canon 18-55 lens the same as 5 years ago? Only got the error message when I separated the commands: $ sudo sh # ./install hope it helps share|improve this answer answered Nov 27 '15 at 22:00 user145114 1
Well, you would be surprised how many shell users ignore the text of error messages! Not the answer you're looking for? Rui PaisAugust 2nd, 2008, 04:15 PMI don't have a graphical interface installed on my server. Here's the script: #!/bin/bash for file in /home/me/box/*/* do dir=$(basename $(dirname "$file")); sudo chmod 0777 /var/log/torrentwatch.log sudo chmod -R 0777 /home/me/box/*/* if "$file" = "/home/me/box/*/*.torrent"; then echo [`date`] "$file" added to
Why do CRs hurt?