Batch 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 syntax error unexpected end of file php Us Learn more about Stack Overflow the company Business Learn more about hiring syntax error unexpected end of file bash developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join
Syntax Error Unexpected End Of File Wordpress
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 Bash syntax error: unexpected end
Syntax Error Unexpected End Of File Bash Script
of file up vote 29 down vote favorite 14 Forgive me for this is a very simple script in Bash. Here's the code: #!/bin/bash # june 2011 if [ $# -lt 3 -o $# -gt 3 ]; then echo "Error... Usage: $0 host database username" exit 0 fi after running sh file.sh: syntax error: unexpected end of file bash syntax share|improve this question edited Jun 17 syntax error unexpected end of file shell script '13 at 10:26 fedorqui 108k30164211 asked Jun 16 '11 at 2:34 markcruz 174127 add a comment| 9 Answers 9 active oldest votes up vote 41 down vote accepted I think file.sh is with CRLF line terminators. run dos2unix file.sh then the problem will be fixed. You can install dos2unix in ubuntu with this: sudo apt-get install dos2unix share|improve this answer answered Jun 16 '11 at 2:50 clyfish 4,98311822 thanks guys! all of you are right. there's something non-unix character embedded on my code! thanks –markcruz Jun 16 '11 at 2:54 thanks! saved me a lot of time! surprised I need to google this many pages before running into this answer. –Derek Jul 3 '13 at 6:01 Whats the reason behind this problem? I usually work on Windows but need to transfer scripts to unix systems. –CMCDragonkai Nov 2 '13 at 16:06 3 Makes no change for me. Downvoting. Sorry. –Kees de Kooter Dec 5 '14 at 8:35 2 @KeesdeKooter I wouldn't say just because something didn't work for you that you should downvote it, clearly it worked for the 28 upvotes. A simple it didn't work fo
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta
Syntax Error Unexpected End Of File Python
Discuss the workings and policies of this site About Us Learn more syntax error unexpected end of file unix about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack syntax error unexpected end of file laravel 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 http://stackoverflow.com/questions/6366530/bash-syntax-error-unexpected-end-of-file each other. Join them; it only takes a minute: Sign up bash script, line 30: syntax error: unexpected end of file up vote 1 down vote favorite I`v wrote some script, and have unexpected end of file echo off if [$JAVA_HOME = ""]; then goto no_java_home fi if [$SRV_HOME = ""]; then goto no_srv_home fi echo Uses http://stackoverflow.com/questions/4032089/bash-script-line-30-syntax-error-unexpected-end-of-file JAVA_HOME=$JAVA_HOME echo Uses SRV_HOME=$SRV_HOME export ACP="" export ACP=$ACP;$JAVA_HOME/lib/tools.jar export ACP=$ACP;$SRV_HOME/ant/lib/ant.jar export ACP=$ACP;$SRV_HOME/ant/lib/ant-launcher.jar export ACP=$ACP;$SRV_HOME/ant/lib/ant-nodeps.jar export ACP=$ACP;$SRV_HOME/ant/lib/optional.jar export ACP=$ACP;$SRV_HOME/ant/lib/ant-contrib-1.0b3.jar $JAVA_HOME/bin/java -Xmx512m -classpath $ACP org.apache.tools.ant.Main -buildfile $SRV_HOME/ant/ant_script.xml %* goto ends no_srv_home: clear echo "You should set the TMX_HOME environment variable. For example: TMX_HOME=d:\MYSERVER" goto ends no_java_home: clear echo "You should set the JAVA_HOME environment variable" goto ends ends: echo "OK" Where is my problem? linux bash shell share|improve this question edited Oct 27 '10 at 14:49 Dennis Williamson 167k42235305 asked Oct 27 '10 at 10:14 slavig 1912316 Bash doesn't have goto or echo off and you have to put a space after [ and before ]. You may not need to export the ACP variable since it is being passed as an argument (does Java look for it in its environment?). –Dennis Williamson Oct 27 '10 at 14:54 add a comment| 3 Answers 3 active oldest votes up vote 3 down vote accepted Your problem is that your script looks like a haphazard mix of bash and cmd syntax. Here's
Out Of Trouble by William Shotts, Jr. Now that our scripts are getting a little more complicated, I want to point out some common mistakes that you might run into. http://linuxcommand.org/wss0100.php To do this, create the following script called trouble.bash. Be sure to enter it exactly as written. #!/bin/bash number=1 if [ $number = "1" ]; then echo "Number equals 1" else https://sourceforge.net/p/modules/mailman/message/23716482/ echo "Number does not equal 1" fi When you run this script, it should output the line "Number equals 1" because, well, number equals 1. If you don't get the expected syntax error output, check your typing; you made a mistake. Empty variables Edit the script to change line 3 from: number=1 to: number= and run the script again. This time you should get the following: [me@linuxbox me]$ ./trouble.bash /trouble.bash: [: =: unary operator expected. Number does not equal 1 As you can see, bash displayed an error message when we ran the script. You syntax error unexpected probably think that by removing the "1" on line 3 it created a syntax error on line 3, but it didn't. Let's look at the error message again: ./trouble.bash: [: =: unary operator expected We can see that ./trouble.bash is reporting the error and the error has to do with "[". Remember that "[" is an abbreviation for the test shell builtin. From this we can determine that the error is occurring on line 5 not line 3. First, let me say there is nothing wrong with line 3. number= is perfectly good syntax. You will sometimes want to set a variable's value to nothing. You can confirm the validity of this by trying it on the command line: [me@linuxbox me]$ number= [me@linuxbox me]$ See, no error message. So what's wrong with line 5? It worked before. To understand this error, we have to see what the shell sees. Remember that the shell spends a lot of its life substituting text. In line 5, the shell substitutes the value of number where it sees $number. In our first try (when number=1), the shell subst
clean. Screenshot instructions: Windows Mac Red Hat Linux Ubuntu Click URL instructions: Right-click on ad, choose "Copy Link", then paste here → (This may not be possible with some types of ads) More information about our ad policies X You seem to have CSS turned off. Please don't fill out this field. You seem to have CSS turned off. Please don't fill out this field. Briefly describe the problem (required): Upload screenshot of ad (required): Select a file, or drag & drop file here. ✔ ✘ Please provide the ad click URL, if possible: Home Browse Environment Modules Mailing Lists Environment Modules Manage your shell environment variables and aliases Brought to you by: leomania, rkowen, sirdude Summary Files Reviews Support Wiki Mailing Lists Code Tickets ▾ Patches Bugs Feature Requests Discussion Git ▾ Environment Modules - C Environment Modules - Tcl Only modules-interest Re: [Modules] modules error during job submission Re: [Modules] modules error during job submission From: Kevin Van Workum