Bash Syntax Error Unexpected Expecting Done
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 parse error syntax error unexpected expecting in framework php on line 42 Us Learn more about Stack Overflow the company Business Learn more about hiring syntax error unexpected expecting keyword_end developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the
Syntax Error Unexpected Expecting End
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 hooks/post-receive: Syntax error: “(” unexpected (expecting
Syntax Error Unexpected Expecting End Syntaxerror
“done”) up vote 2 down vote favorite 2 I am writing a post-receive script in GIT. I attach a minimal version of it, which also fails: generate_email() { for user in $(git config --get-all notifications.users); do unset files_to_notify for filter in $(git config --get-all notifications.$user); do files_to_notify=" $files_to_notify $(git diff-tree --no-commit-id \ --name-only -r $newrev | grep $filter) " done files_to_notify=( $files_to_notify ) if [ -n "$files_to_notify" ruby syntax error unexpected expecting ]; then echo ${files_to_notify[*]} fi done } while read oldrev newrev refname do generate_email $oldrev $newrev $refname done When I'm trying to push to git server in invoke this script, I get the following message: remote: hooks/post-receive: 10: hooks/post-receive: Syntax error: "(" unexpected (expecting "done") When I try to run it in command-line, the script works correctly without this message. Any Ideas? Thanks, Elyashiv git bash share|improve this question asked Feb 11 '13 at 8:07 ElyashivLavi 400313 1 And what files_to_notify=( $files_to_notify )is supposed to do? –VonC Feb 11 '13 at 8:48 add a comment| 1 Answer 1 active oldest votes up vote 3 down vote accepted Two possibilities: Add #!/usr/bin/env bash to the top of the script to ensure the script is run by bash and not sh, since you use an array, a bash extension. Stop using the array, since you don't use it in any way that couldn't easily be replaced with a simple space-delimited string. That's how you are building the array in the first place. share|improve this answer answered Feb 11 '13 at 13:59 chepner 136k12119194 Thanks for the answer! I used bash, and it solved the issue. –Elyas
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 answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the
Syntax Error Unexpected In Shell Script
company Business Learn more about hiring developers or posting ads with us Ask Ubuntu syntax error ( unexpected bash array Questions Tags Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; ksh syntax error unexpected 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 top Unexpected EOF in a bash script, why? http://stackoverflow.com/questions/14808114/hooks-post-receive-syntax-error-unexpected-expecting-done up vote 3 down vote favorite I can't normally run sh scripts. It's confusing. I set the permissions to 777 and +x so it should work with the 'sh' command, right... But it's working very strange. For example this scripts works ok: echo "hello" it prints "hello" with no errors. But this script: #!/bin/bash for i in `seq 1 5`; do echo $i done ...outputs this error: Syntax error: end of file unexpected (expecting "done") http://askubuntu.com/questions/340767/unexpected-eof-in-a-bash-script-why Is there something wrong with that loop? command-line bash scripts share|improve this question edited Sep 3 '13 at 21:57 Braiam 38.8k1691153 asked Sep 3 '13 at 8:29 user568021 2952619 How do you run the above script? The loop it looks ok. –Radu Rădeanu Sep 3 '13 at 8:32 I run it with the sh command: sh script.sh –user568021 Sep 3 '13 at 8:36 You defined bash and not sh for your script, so run it with bash script.sh –Frantique Sep 3 '13 at 8:37 2 Are you sure that you have the last line (done) in your original script (script.sh)? –Radu Rădeanu Sep 3 '13 at 8:38 @Frantique This problem does nothing have to do with your observation. –Radu Rădeanu Sep 3 '13 at 8:41 | show 2 more comments 1 Answer 1 active oldest votes up vote 7 down vote accepted The problem it is, that you probably made a Ctrl+C Ctrl+V from a website, and the end-of-line char there was something strange, not printable character. (You can make it visible by dumping to hex the file.) Please open your file in an editor, and retype everything manually, or at least remove the last eol characters, save your work, and try again. share|improve this answer answered Sep 3 '13 at 8:42 Frantiqu
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code of Conduct Ubuntu https://ubuntuforums.org/showthread.php?t=1838432 Wiki Community Wiki Other Support Launchpad Answers Ubuntu IRC Support AskUbuntu Official https://ubuntuforums.org/showthread.php?t=1130892 Documentation User Documentation Social Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu PPAs: Ubuntu Web Upd8: Ubuntu OMG! Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO login Advanced Search Forum The Ubuntu Forum Community Ubuntu Official Flavours Support General Help [SOLVED] bash - expecting syntax error "fi" but it is already there Having an Issue With Posting ? Do you want to help us debug the posting issues ? < is the place to report it, thanks ! Page 1 of 3 123 Last Jump to page: Results 1 to 10 of 21 Thread: bash - expecting "fi" but it is already there Thread syntax error unexpected Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode September 3rd, 2011 #1 SeaKing View Profile View Forum Posts Private Message A Carafe of Ubuntu Join Date Jul 2011 Location Germany Beans 88 DistroUbuntu 12.04 Precise Pangolin bash - expecting "fi" but it is already there I've wrote a little bash script to ease the installation of programs which are not part of the standard installation of ubuntu: Code: #! /bin/bash #installing ubuntu-restricted-extras vlc, SUN Java, handbrake, bumblebee (hybrid graphics management tool), skype, pidgin, Thunderbird echo "" echo "" echo "Willkommen bei der Installationsroutine fuer das Asus X5MSN" echo "------------------------------------------------------------" echo "" if [ "$(whoami)" != "root" ]; then echo "Das Script muss mit root-Rechten ausgefuehrt werden!" echo "Nutze: 'sudo ./script.sh'" echo "" else echo "Installation der Ubuntu-Restricted-Extras ..." apt-get -y install ubuntu-restricted-extras echo "done" sleep 5 echo "Installation des VLC-Players ..." echo "--------------------------------" apt-get -y install vlc vlc-data echo "done" sleep 5 echo "Hinzufuegen der PPA: Paketquellen fuer SUN JAVA, Handbrake und bum
Get Kubuntu Get Xubuntu Get Lubuntu Get UbuntuStudio Get Mythbuntu Get Edubuntu Get Ubuntu-GNOME Get UbuntuKylin Ubuntu Code of Conduct Ubuntu Wiki Community Wiki Other Support Launchpad Answers Ubuntu IRC Support AskUbuntu Official Documentation User Documentation Social Media Facebook Twitter Useful Links Distrowatch Bugs: Ubuntu PPAs: Ubuntu Web Upd8: Ubuntu OMG! Ubuntu Ubuntu Insights Planet Ubuntu Activity Page Please read before SSO login Advanced Search Forum The Ubuntu Forum Community Ubuntu Official Flavours Support New to Ubuntu [ubuntu] Syntax error: word unexpected (expecting "do") Having an Issue With Posting ? Do you want to help us debug the posting issues ? < is the place to report it, thanks ! Results 1 to 6 of 6 Thread: Syntax error: word unexpected (expecting "do") Thread Tools Show Printable Version Subscribe to this Thread… Display Linear Mode Switch to Hybrid Mode Switch to Threaded Mode April 20th, 2009 #1 rohandeshmukh View Profile View Forum Posts Private Message First Cup of Ubuntu Join Date Apr 2009 Beans 3 Syntax error: word unexpected (expecting "do") Hi! i am writting a code to delete excel reports older than one day. The code is as follows: path="/home/directory/Reports" echo "The reports older than one day are getting deleted..." for i in `find $path/*.xls -mtime +1 -print` do echo "File $i is deleted" sudo rm $i done echo "Deletion is completed" When i am executing this script, it is giving me the error that Syntax error: word unexpected (expecting "do") but if i write the same code on command prompt instead of in shell script, it is getting executed properly. Please let me know where i am getting wrong. Thanks in advance Adv Reply April 20th, 2009 #2 leandromartinez98 View Profile View Forum Posts Private Message Tea Glorious Tea! Join Date Apr 2008 Location Campinas, SP - Brasil Beans 355 Re: Syntax error: word unexpected (expecting "do") Put this in the first line of your script file: #!/bin/sh This sets which interpreter you are using (in this case, sh, or bash). This may solve the problem. I cannot see anything else now. Just for curiosity: Do you really need root privileges to delete the files? (Is the use of "sudo" necessary, it seems strange, and dangerous). Adv Reply April 20th, 2009 #3 mister_pink View Profile View Forum Posts Private Message Quad Shot of Ubuntu Join Date Oct 200