Home > Syntax Error > Unix Syntax Error Unexpected

Unix Syntax Error Unexpected


Bash 4.0 added an extra message for this: warning: here-document at line delimited by end-of-file (wanted `') Unexpected end of file while looking for matching ... To fix the issue use bash instead of using sh while executing the script, that should not throw any syntax error. But when I run this on the other server I get: Syntax error: "(" unexpected As far as I can tell both servers are the same. It reads the /etc/power.conf file. http://crimsonskysoftware.com/syntax-error/unix-syntax-error-near-unexpected-token.html

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... Try the following. What does this ice key do? On Debian, sh is usually dash which has no array support (a[index]=x won't work). –Stéphane Chazelas Jan 7 at 15:38 add a comment| up vote 0 down vote Running ./scriptname.sh will http://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected

Syntax Error ( Unexpected Bash Array

bash array.sh should work fine. 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. The various parts of the script prompt are printed in color. asked 2 years ago viewed 4056 times active 10 months ago Linked 2 Syntax error: “(” unexpected (expecting “done”) 0 Error with simple shell script Related 18Bash array: Unexpected Syntax error34Bash

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 The real problem is that: a) some people equate sh with bash, and b) bash does a poor job of emulating sh. I can't figure out problem. Line 1: Syntax Error: Unexpected Word (expecting ")") share|improve this answer answered Aug 18 '12 at 12:08 Gilles 374k706831129 1 Thanks clearly a gap in my knowledge, I don't script much so wasn't aware of that!

Try comparing sh --version on both machines. It's easy to imagine the ^M is bad in other places too. That's just masking the problem, so I think it's a bad idea. https://ubuntuforums.org/archive/index.php/t-499045.html For me, the Ubuntu OS is mere curiosity.

It would appear that when I run it as sh scriptname.sh I get the error, but if I run it as ./scriptname.sh it seems to be ok. Bash Function Syntax Error Unexpected share|improve this answer edited Aug 9 '14 at 20:50 answered Aug 9 '14 at 20:23 Keith Thompson 148k19196349 add a comment| up vote 1 down vote Instead of using sh to How can I make two cutting lines close to each other? "Squeezing out of a dead man" proverb In lightning component, are only html items responsive at all? From my personal experience, I can suggest vim or GNU emacs.

Syntax Error At Line 1 (' Unexpected In Shell Script

There's a big difference in the way that UNIX® and Microsoft® (and possibly others) handle the line endings of plain text files. http://stackoverflow.com/questions/29287474/syntax-error-unexpected-expecting-done bash shell-script array share|improve this question edited Jan 7 at 23:36 Gilles 374k706831129 asked Jan 7 at 14:42 IGGt 398314 Did you copy-pasted the script between the two server? Syntax Error ( Unexpected Bash Array You should be able to run your bash scripts with the bash command even if your default shell is i.e. Syntax Error ( Unexpected Ubuntu Grab a bash binary of the same version from somewhere and manually install it.

Beautiful. navigate here There is nothing about this line running as sudo that should stop it working to my knowledge, does anyone have any ideas? Why does removing Iceweasel nuke GNOME? Thanx. #!/bin/bash color_def="~/.colorrc" if -f $color_def; then . $color_def else # color definitions black="$(tput setaf 0)" darkgrey="$(tput bold ; tput setaf 0)" lightgrey="$(tput setaf 7)" white="$(tput bold ; tput setaf 7)" Ksh Syntax Error Unexpected

But It's run on centos without any issues. #!/bin/sh # TODATE=`date '+%Y-%b-%d'` # # Backup Creation for Databases # databases=(`echo 'show databases;' | mysql -u root -ppaSSword | grep -v ^Database$`) Remove advertisements Sponsored Links rwb1959 View Public Profile Visit rwb1959's homepage! works fine! Check This Out After executing these commands, bash array.sh produced the desired result.

did you close your ( with a )? Syntax Error At Line 1 (' Unexpected Solaris Was running wrong arch executable. If the default colors are not suitable than you can set the environment varialbes script_color linenum_color funcname_color to any of the following colors: ${darkgrey}darkgrey$nc, ${lightgrey}light grey$nc, ${white}white, ${red}red, ${lightred}light red, ${green}green,

Executing sudo sh ./sonar.sh console.

They are especially bad when present in the shebang/interpreter specified with #! Try our newsletter Sign up for our newsletter and get our top new questions delivered to your inbox (see an example). Several possible fixes: Reinstall bash: sudo aptitude reinstall bash Upgrade to Hardy Download the bash source package, bump the version number, build the package, and install it. Sh: 1: Syntax Error: "(" Unexpected Python All Rights Reserved.

Integer function which takes every value infinitely often What do you call someone without a nationality? 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. What was that alien in Doctor Who that nobody saw? this contact form Integer function which takes every value infinitely often Output a googol copies of a string very lightweight low power microcontroller with memory?

Use a unique name for your script Do not name your script test, for example! making new symbol from two symbols Watching order for the Dan Brown films? script.sh: line 50: unexpected EOF while looking for matching `"' script.sh: line 100: syntax error: unexpected end of file This one indicates the double-quote opened in line 50 does not have 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

My system is still not quite right, but the aptitude reinstall bash worked in that I now have bash again. Given a limit with notation f, how would you solve? Example:  Run arrays.sh as $ bash arrays.sh -Sany Rate this:Share this:ShareTweetPocketShare on TumblrEmailPrintLike this:Like Loading... The proper solution, of course, is to fix the scripts, which are buggy by definition.

If you're lucky, you'll get: bash: ./testing.sh: /bin/bash^M: bad interpreter: No such file or directory which alerts you to the CR. I have a suggestion for putting in DEBUG switches. Syntax highlighting helps you see (you guessed it) syntax errors, such as unclosed quotes and braces, typos, etc. My Ubuntu version 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,49162355 sh array.sh

How are you running the posted script (which is run_all_verification.sh I'm assuming)? ./run_all_verification.sh? share|improve this answer answered Aug 26 '14 at 0:34 R J 29112 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google In order to solve the issue, I found a link where it was described to be gone by using the following code. If it's printed to your terminal, a carriage return will effectively place the cursor at the beginning of the current line.

In summary, CRs are a pain. 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