Bin/sh Function Syntax Error Unexpected
Contents |
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 bin sh c line 1 syntax error unexpected end of file more about Stack Overflow the company Business Learn more about hiring developers or posting
Bin Sh C Line 0 Syntax Error Near Unexpected Token
ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a
Syntax Error Unexpected Expecting Function
question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer
Syntax Error Unexpected Function T_function
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 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 parse error syntax error unexpected function 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 Ubuntu's DashAsBinSh affinity I suspect your script is interpreted by dash instead of bash. Try to move the shebang in line 1. –manatwork Aug 18 '12 at 11:45 According to that article calling /bin/bash directly instead of /bin/sh will; correctly use bash instead of dash so that should not be an issue as I understand it. I can still move the sheban
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 syntax error unexpected in shell script the company Business Learn more about hiring developers or posting ads with us Stack syntax error ( unexpected bash array Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of syntax error at line unexpected 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up bash Syntax error: “(” unexpected up vote 5 down vote favorite 1 For some reason this function is http://unix.stackexchange.com/questions/45781/shell-script-fails-syntax-error-unexpected working properly, the terminal is outputting newbootstrap.sh: 2: Syntax error: "(" unexpected Here is my code (line 2 is function MoveToTarget() {) #!/bin/bash function MoveToTarget() { #This takes to 2 arguments: source and target cp -r -f "$1" "$2" rm -r -f "$1" } function WaitForProcessToEnd() { #This takes 1 argument. The PID to wait for #Unlike the AutoIt version, this sleeps 1 second while [ $(kill -0 "$1") ]; do sleep http://stackoverflow.com/questions/6347119/bash-syntax-error-unexpected 1 done } function RunApplication() { #This takes 1 application, the path to the thing to execute exec "$1" } #our main code block pid="$1" SourcePath="$2" DestPath="$3" ToExecute="$4" WaitForProcessToEnd $pid MoveToTarget $SourcePath, $DestPath RunApplication $ToExecute exit linux osx bash scripting syntax-error share|improve this question edited Mar 2 at 20:59 Jens 36.2k863104 asked Jun 14 '11 at 16:50 rsmith 2613 add a comment| 2 Answers 2 active oldest votes up vote 17 down vote You're using the wrong syntax to declare functions. Use this instead: MoveToTarget() { # Function } Or this: function MoveToTarget { # function } But not both. Also, I see that later on you use commas to separate arguments (MoveToTarget $SourcePath, $DestPath). That is also a problem. bash uses spaces to separate arguments, not commas. Remove the comma and you should be golden. share|improve this answer edited Jun 14 '11 at 16:58 answered Jun 14 '11 at 16:52 Rafe Kettler 40.3k12104123 Thanks! It makes sense now. I saw some websites that did that. –rsmith Jun 14 '11 at 16:53 1 @rsmith that website was incorrect, then. –Rafe Kettler Jun 14 '11 at 16:53 @rsmith Name the site or it was a dream :-) –Jens Mar 2 at 21:00 add a comment| Did you find this question int
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 http://stackoverflow.com/questions/25222259/i-am-getting-error-array-sh-3-array-sh-syntax-error-unexpected About Us Learn more about Stack Overflow the company Business Learn 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 syntax error error “array.sh: 3: array.sh: Syntax error: ”(“ unexpected” up vote 3 down vote favorite 2 I have written the following code: #!/bin/bash #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 syntax error unexpected "#!/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 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 ${a