Home > Syntax Error > Bash Array Syntax Error Unexpected

Bash Array Syntax Error Unexpected

Contents

[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 I accepted a counter offer and regret it: can I go back and contact the previous company? Search this Thread 05-22-2008, 05:51 PM #1 williamhomanchun LQ Newbie Registered: Apr 2008 Posts: 17 Rep: How to use array in sh shell Hi all, I am trying to 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? his comment is here

Natural construction Religious supervisor wants to thank god in the acknowledgements Activate Hearthstone season chest cards? spectral norm of block-wise sums of matrices How to deal with a really persuasive character? Thanks for the clarification! –dave_alcarin Jan 8 at 8:44 add a comment| up vote 0 down vote With sh scriptname.sh, you are running it with sh, not necessarily with bash. My girlfriend has mentioned disowning her 14 y/o transgender daughter A simple visual puzzle to die for The Woz Monitor Did Donald Trump call Alicia Machado "Miss Piggy" and "Miss Housekeeping"?

Bash Syntax Error Unexpected Token

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 What could cause the throttle to stick in my Ford Ranger? See if your system has dos2unix then use it like dos2unix myScript.sh Also, as several people have commented on it, please edit your original question to eliminate the spaces around your share|improve this answer answered Jun 14 '12 at 3:30 Chad Walstrom 416 I understand that> I executed the very same commands directly on the terminal and it worked.

It prints blank. The sh shell has no syntax to create arrays, but Bash has the syntax you used. or, alternatively, a SHELL=/bin/bash line in your crontab, assuming your version of cron supports that, which most modern Linux distros seem to... –twalberg Mar 4 '13 at 19:53 1 Oh! Syntax Error Unexpected Array Php How to indicate you are going straight?

UNIX is a registered trademark of The Open Group. Bash Syntax Error Unexpected End Of File The Woz Monitor How to pluralize "State of the Union" without an additional noun? thank you everyone... share|improve this answer answered Jan 7 at 15:02 dave_alcarin 5651212 1 sh is not necessarily the "user's standard shell" it's often its own executable (or symlink) and sh will be

This is my first time in shell programming so I am unable to fix the issues myself. Syntax Error Unexpected In Shell Script 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:53 add a comment| up vote 0 down vote Also sometime it's because of extra space: array = (1 2 3 4) is not right. One possibility: Could you cut and paste the exact error message you're getting?

Bash Syntax Error Unexpected End Of File

up vote 2 down vote favorite I have been searching everywhere for an answer to this question. Put your script thru this test cat -vet myScript.sh Do you see '^M' chars at the end of lines? Bash Syntax Error Unexpected Token And/or with dpkg -S $(which sh). Syntax Error Unexpected End Of File Bash Script Why are some programming languages Turing complete but lack some abilities of other languages?

Browse other questions tagged bash shell-script array or ask your own question. http://onlinetvsoftware.net/syntax-error/bash-array-syntax-error-word-unexpected-expecting.php How's the CMD trip bonuses from extra legs work? 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? share|improve this answer answered Aug 9 '14 at 20:00 Mistu4u 1,46662352 3 Strange. Shell Script Array Syntax Error Unexpected

One possible explanation would be if you had a space character in between the equal sign and the open parenthesis, in which case you'd get the following: [email protected]:~/stuff$ ./test ./test: line I will try running the script as you did when I get home from work, and see if I get the same results. 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 http://onlinetvsoftware.net/syntax-error/bash-array-syntax-error-unexpected-expecting.php When I executed it as ./test.sh it worked fine! –user1357576 Jun 14 '12 at 3:50 Ah yes, sh is not alway 'sh'.

When I copy paste entire script into terminal, it works. Bash Function Syntax Error Unexpected If so that is a dos file. Can Customs make me go back to return my electronic equipment or is it a scam?

There are no arrays in sh.

If you execute the script by typing ./array.sh the system will pay attention to the #!/bin/bash line and execute the script using /bin/bash. Unix & Linux Stack Exchange works best with JavaScript enabled Ubuntu Forums > The Ubuntu Forum Community > Ubuntu Specialised Support > Development & Programming > Programming Talk > Problem With [email protected]:~$ array =(a b) bash: syntax error near unexpected token `(' [email protected]:~$ array= (a b) bash: syntax error near unexpected token `(' [email protected]:~$ array = (a b) bash: syntax error near Shell Script Array linux shell cron crontab share|improve this question asked Mar 4 '13 at 19:34 vikash 2819 2 Do you have #!/bin/bash at the top of script.sh? –chepner Mar 4 '13 at

How to map and sum a list fast? Train ride from Copenhagen to Malmo How to handle spending money for extended trip to Europe? 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 check over here Ash) and be the case that that other interpreter does not support arrays as Bash does.

In your own answer, you say you fixed the problem by using chsh to change your default login shell to /bin/bash. Example:  Run arrays.sh as $ bash arrays.sh -Sany Rate this:Share this:ShareTweetPocketShare on TumblrEmailPrintLike this:Like Loading... Not the answer you're looking for? Cheers.

bash array.sh should work fine.