Home > Syntax Error > Bash Array Syntax Error Unexpected

Bash Array Syntax Error Unexpected


Join them; it only takes a minute: Sign up Syntax error: “(” unexpected assigning an array in bash up vote 0 down vote favorite Within a bash script, I'm trying to What could cause the throttle to stick in my Ford Ranger? One possibility: Could you cut and paste the exact error message you're getting? munkyeetrMay 15th, 2007, 04:33 PMThank you for the time spent experimenting, and the advice. this contact form

But it can be invoked as "sh -c {script}" or "dash -c {script}", and the "#!/bin/bash" *is* correctly handled to invoke the bash shell. more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed Browse other questions tagged arrays bash shell syntax or ask your own question. Works only in a modern bash (from 3.x on , I guess) uhelp View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by uhelp

Bash Syntax Error Unexpected Token

Limit involving exponentials and arctangent without L'Hôpital Are there any 'smart' ejection seats? What to tell to a rejected candidate? Lloyd B. It's a normal, numerically indexed array. –Dennis Williamson Jun 14 '12 at 3:46 @DennisWilliamson Oh Ok.

QuikeeMay 15th, 2007, 02:27 PMI did my own example and "a=( a b c )" works for me.. Why does Windows show "This device can perform faster" notification if I connect it clumsily? How rich can one single time travelling person actually become? Syntax Error Unexpected Array Php I hope this helps.

spectral norm of block-wise sums of matrices How to handle spending money for extended trip to Europe? Bash Syntax Error Unexpected End Of File Rosa Parks is a [symbol?] for the civil rights movement? What to tell to a rejected candidate? alinas View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by alinas 04-05-2012, 10:45 AM #9 uhelp Member Registered: Nov 2011 Location: Germany,

Can Customs make me go back to return my electronic equipment or is it a scam? Syntax Error Unexpected In Shell Script Are you perhaps running sh yourscript? asked 3 years ago viewed 573 times active 1 year ago Linked 0 Error 'Syntax error: “(” unexpected' when declaring arrays in bash Related 3Creating a Temporary Cron Job From the Simpler to just run "./test", which works correctly regardless of your default shell, and only invokes an extra copy of "bash" if one is required.

Bash Syntax Error Unexpected End Of File

Join them; it only takes a minute: Sign up array declaration of shellscript doesnot work in scheduled cron job? Main Menu LQ Calendar LQ Rules LQ Sitemap Site FAQ View New Posts View Latest Posts Zero Reply Threads LQ Wiki Most Wanted Jeremy's Blog Report LQ Bug Syndicate Latest Bash Syntax Error Unexpected Token Also, don't edit the title to resolve it, the website will mark the question as solved when you accept an answer. –Daenyth Jun 14 '12 at 4:01 add a comment| 3 Syntax Error Unexpected End Of File Bash Script This is an interesting problem, so I did a little experimentation: From a "bash" shell (which is my default), the script works correctly if invoked as "./test", or "bash ./test", but

One more question: Since I never use the dash shell, it should be safe to redirect my sh link to /bin/bash, yes or no? http://waspsoft.com/syntax-error/bash-array-syntax-error-word-unexpected-expecting.html Create with: set +A myarray value1 value2 value3 ... yes I did not add #!/bin/bash. Not the answer you're looking for? Shell Script Array Syntax Error Unexpected

That will give you exactly the error message that you report. lloyd_bMay 15th, 2007, 04:06 PM. ..which makes sense (now) because my link to sh points to the dash shell. But when you use sh scriptname.sh it executes sh, not bash. http://waspsoft.com/syntax-error/bash-array-syntax-error-unexpected-expecting.html Is 8:00 AM an unreasonable time to meet with my graduate students and post-doc?

Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. Bash Function Syntax Error Unexpected Why are some programming languages Turing complete but lack some abilities of other languages? Find More Posts by konsolebox View Blog 04-04-2012, 07:36 AM #5 expert_vision LQ Newbie Registered: Mar 2011 Posts: 13 Rep: Quote: Originally Posted by konsolebox or you can use

How to increase the population growth of the human race What are the holes on the sides of a computer case frame for?

Dec 9 '11 at 7:35 @user1068559 you can try running the script with sh --verbose -x script.sh and see where it actually breaks tldp.org/LDP/abs/html/arrays.html might help you as well Why write an entire bash script in functions? Is this safe to display MySQL query error in webpage if something went wrong? Shell Script Array The Woz Monitor How to pluralize "State of the Union" without an additional noun?

If I type it into the terminal directly it is fine?? 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 asked 2 years ago viewed 3927 times active 9 months ago Linked 2 Syntax error: “(” unexpected (expecting “done”) 0 Error with simple shell script Related 18Bash array: Unexpected Syntax error34Bash http://waspsoft.com/syntax-error/bash-array-syntax-error-near-unexpected-token.html So the issue is that running a shell script as "sh {script}" or "dash {script}" bypasses the "#!/bin/bash" line, thus causing it to fail.

I know the script works, so it must be some kind of quirk with something else. –Michael S. something like: Code: /bin/sh for i in `seq 1 5`; do array$i=$i done won't work. To fix the issue use bash instead of using sh while executing the script, that should not throw any syntax error. 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).

[email protected]:~/Desktop$ ls -l /bin/*sh -rwxr-xr-x 1 root root 676836 2006-09-19 15:24 /bin/bash -rwxr-xr-x 1 root root 79912 2006-07-11 12:31 /bin/dash lrwxrwxrwx 1 root root 4 2007-05-13 09:13 /bin/rbash -> bash lrwxrwxrwx share|improve this answer edited Jan 7 at 23:37 Gilles 369k666681119 answered Jan 7 at 15:06 Konstantin Morenko 1986 OK, that makes sense now.