Cygwin Bash Syntax Error Unexpected End Of File
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 more about Stack Overflow the company Business Learn more
Syntax Error Unexpected End Of File Bash Script
about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users syntax error unexpected end of file php Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping syntax error unexpected end of file wordpress each other. Join them; it only takes a minute: Sign up Cygwin error when doing if…then…fi - Bash script up vote 4 down vote favorite I just started bash shell programming. I have installed Cygwin on my Windows 7
Syntax Error Unexpected End Of File Shell Script
computer. I started writing a script using this tutorial. My script requires an argument to be passed to it, if it doesn't it should display an error message. This is the code directly from the tutorial and the same one in my code: [ $# -eq 0 ] && { echo "usage: someArgument"; exit 1; } When I do the following: sh ./myscript.sh it gives me this error: -bash: /home/Me/myscript.sh: line 5: syntax error: unexpected end of
Syntax Error Unexpected End Of File Python
file "Unexpected end of file" means I have missed a fi or done, etc. somewhere. I double-checked my code, but found nothing. Plus, when I comment out the line the script works perfectly fine. I tried using a if...then...fi: if [ $# -eq 0 ] then echo "usage: someArgument" exit 1; fi but to no avail! Please help, it's been stumping me. linux bash shell if-statement cygwin share|improve this question asked Jul 15 '12 at 6:38 Arka Majumdar 1,4981336 2 Consider providing an exact script reproducing your problem. It is not clear where your line "5" is. –user405725 Jul 15 '12 at 6:41 @torrentialcoding I am using Notepad++. I just noticed in the bottom right corner the words change from Dos/Windows to UNIX when I run dos2unix on the script (see my answer). –Arka Majumdar Jul 15 '12 at 8:33 @Java I believe Notepad++ allows you to save a file in Unix mode. This will save you an extra step of having to run the dos2unix tool to make your scripts usable. –torrential coding Jul 15 '12 at 8:51 @torrentialcoding Yeah it does. You can go to Edit>EOL Conversion>UNIX Format, or set as default under Peferences. That's good news :) –Arka Majumdar Jul 15 '12 at 9:39 add a comment| 3 Answers 3 active oldest votes up vote 5 down vote ac
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies syntax error unexpected end of file unix of this site About Us Learn more about Stack Overflow the company
Syntax Error Unexpected End Of File Laravel
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users syntax error unexpected end of file expecting function (t_function) 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 http://stackoverflow.com/questions/11489982/cygwin-error-when-doing-if-then-fi-bash-script minute: Sign up syntax error: unexpected end of file trying to run a simple bash script up vote 1 down vote favorite I really can't see what the issue is with my script is. I've considered missing quotations or other syntax errors. There's got to be something I'm missing. It's a very simple while loop script... #!/bin/bash c=1 while [ $c -le http://stackoverflow.com/questions/31216532/syntax-error-unexpected-end-of-file-trying-to-run-a-simple-bash-script 5 ] do echo "Welcone $c times" c=$(( c++ )) done I should mention that I'm running bash in cygwin on windows 7. thanks for the help bash cygwin eof share|improve this question asked Jul 4 '15 at 3:14 user3671613 1315 Could it be a strange Windows whitespace character? I tried running it in Linux and got the following output. –Huey Jul 4 '15 at 3:18 Did you use a windows editor (like Notepad) to create this file? If so, you've probably got end-of-line problems. Try using dos2unix to convert it (and read the man page, it overwrites its input). –bishop Jul 4 '15 at 3:24 probably is. I guess I just wont think about it too much and I'll try running it in linux when I can. (I can't install dos2unix in windows with sudo apt-get apparently... if you have a workaround I'd appreciate it ^ ^) –user3671613 Jul 4 '15 at 3:29 Use Notepad++ on windows. It has a setting for line endings (and syntax highlighting, etc). –ooga Jul 4 '15 at 3:31
Articles Search Tutorials http://bethecoder.com/applications/how-to-fix/cygwin/syntax-error-unexpected-end-of-file.html Products Authors Submit a Tutorial Report a Bug Interview FAQ Subscribe How to Fix > Cygwin > Syntax error unexpected end of file Syntax error unexpected end of file The following problem mainly occurs in Cygwin when you try to run a shell script syntax error which is edited or created in DOS/Windows or old Mac systems. Problem Syntax error : unexpected end of file In DOS/Windows text files new line is a combination of two characters : a Carriage Return (\r) followed by Line Feed (\n) character. In Mac prior syntax error unexpected to Mac OS X, a line break was single Carriage Return (\r) character. Linux/Unix and Modern Mac OS uses Unix style Line Feed (\n) line breaks. Cygwin fails to process the scripts formatted in DOS/Windows or old Mac OS because of the extra Carriage Return (\r) character. To solve the problem use dos2unix.exe command to convert the script to Unix readable format. Tweet Print Subscribe Books Recommendation Home | Tutorials | Random Tutorial | Articles | Videos | Search | Google Search | Products | Student Projects | Open Source Tools | Tips And Tricks | How to Fix | Tag Cloud | Share | Disclaimer | Privacy | Contact Send your comments, suggestions or queries regarding this site to bethecoder@gmail.com. Copyright © 2008-2015. All rights reserved.