Linux 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 about hiring
Bash Unexpected End Of File While Looking For Matching
developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask syntax error unexpected end of input Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join
Shell Script Validator
them; it only takes a minute: Sign up Bash syntax error: unexpected end 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 syntax error unexpected end of file python 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 '13 at 10:26 fedorqui 110k30167217 asked Jun 16 '11 at 2:34 markcruz 174127 add a comment| 9 Answers 9 active oldest votes up vote 42 down vote accepted I think file.sh is with CRLF line terminators. run dos2unix file.sh syntax error: end of file unexpected (expecting "then") 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,99311822 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 for me suffices. That's why SO allowed multiple answers to a question because there can be multiple solutions to a problem. –Jeff Wilbert Jul 27 '15 at 15:33 | show 2 more comments up vote 30 down vote Another thing to check (just occured to me): terminate bodies of single-line functions with semicolon I.e. this innocent-looking snippet will cause the same error: die () { test -n "$@" && echo "$@"; exit 1 } To make the dumb parser happy:
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
Syntax Error Near Unexpected Token `fi'
about Stack Overflow the company Business Learn more about hiring developers or posting ads syntax error near unexpected token `done' with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question
Crlf Line Terminators
and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best http://stackoverflow.com/questions/6366530/bash-syntax-error-unexpected-end-of-file answers are voted up and rise to the top Got “syntax error near unexpected end of file” in bash script up vote 0 down vote favorite 2 I'm making an script that gives me a day like this jjj/yyyy when I give it a day like this dd/mm/yyyy and I need it to have an error when you don't write correctly but I'm starting and it's not working :( #! /bin/bash http://unix.stackexchange.com/questions/155166/got-syntax-error-near-unexpected-end-of-file-in-bash-script #Primero debes ingresar el mes echo "Ingresa el número de un mes del año" read mes #Condicional #Dependiendo si coloca bien $mes if [ "$mes" -lt 12 -a "$mes" -gt 0 ]; then echo "muy bien, sigamos." else if [ "$mes" -gt 12 -a "$mes" -lt 0 ]; then echo "Creo que eso ya no es un mes!"; exit fi When I run it it says "syntax error near unexpected end of file" Can anyone help me? bash shell scripting share|improve this question edited Sep 12 '14 at 3:59 cuonglm 72k13116200 asked Sep 12 '14 at 3:59 Divshah 1113 Yes, someone can help you. –Anthon Sep 12 '14 at 4:05 Your code doesn't make sense. A number cannot be at the same time less than 0 and greater than 12, so your second condition can never be true. Also note that -lt and -gt are for strictly greater. -lt 12 and -gt 0 means from 1 to 11. Use -le for less than or equal. –Stéphane Chazelas Jul 28 at 7:33 add a comment| 2 Answers 2 active oldest votes up vote 8 down vote You missed a fi for inner if: if [ "$mes" -lt 12 -a "$mes" -gt 0 ]; then echo "muy bien, sigamo
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss http://unix.stackexchange.com/questions/193296/syntax-error-unexpected-end-of-file-bash-script the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Unix & Linux http://askubuntu.com/questions/485567/unexpected-end-of-file Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. syntax error 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 top Syntax Error: unexpected end of file — Bash script [duplicate] up vote -1 down vote favorite This question already has an answer here: Syntax Error: unexpected end of unexpected end of file — Bash script [closed] 1 answer I am trying to create an spritz app! Everything was working fine, but since yesterday I keep getting this error: ./spritz: line 176: syntax error: unexpected end of file I have checked the script file and everything seems perfect! I am confused I have an if statement at last and it looks correct! Here is the last portion: #checks if speed is 150 157 if [[ $2 -eq 150 ]]; 158 then 159 starttime=$SECONDS 160 FS=$'\n' 161 for j in `grep --color=always -iP '\b[^aeiou\s]*[aeiou][^aeiou\s]*\K[aeiou]' $1`; 162 do 163 #Reads the text file in the centre of the screen 164 echo " ___________________" 165 echo " $j"; 166 echo " ___________________" 167 echo " Speed 150 wpm" 168 sleep 0.9; 169 clear; 170 done 171 endtime=$(($SECONDS - $starttime)) 172 echo "You read $words_read words in $endtime seconds!" 173 exit 8 174 fi bash scripting share|improve this question asked Mar 28 '15 at 17:13 John Selm migrated from serverfault.com Mar 30 '15 at 4:29 This question came from our site for system a
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 company Business Learn more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users Badges Unanswered Ask Question _ Ask Ubuntu is a question and answer site for Ubuntu users and developers. 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 top Unexpected end of file up vote 4 down vote favorite Can someone explain why the end of the file is unexpected on line 49? (Line 49 is one line after the last line) #!/bin/bash timeend=$(date -u +%H%M) timestart=$(date --date "$timeend 30 minutes ago" -u +%H%M) firsttime=0 while true do if [[ $firsttime -eq 0 ]]; then time=$timestart increment=0 fi if [[ $firsttime -ne true ]]; then increment=$(( $increment + 2 )) time=$(( $timestart + $increment )) fi if [[ $time -ge $timeend ]]; then break fi gpnids << EOF RADFIL = NEXRIII|CLT|TR0 RADTIM = "$time" TITLE = 1/-2 PANEL = 0 DEVICE = gif|radar"$increment".gif|1280;1024|C CLEAR = Y TEXT = 1/2/2/hw COLORS = 7 WIND = LINE = CLRBAR = IMCBAR = 5/v/LL/.005;.6/.4;.01 GAREA = dset MAP = 24 + 23 + 1/1/2 + 14 + 15/1/2 LATLON = 0 OUTPUT = t $mapfil = lorvus.usg + hicnus.nws + hipona.nws + louhus.nws + loisus.nws run exit EOF firsttime=1 gpend done bash share|improve this question asked Jun 19 '14 at 16:11 WxPilot 1681215 This question might be better asked on 'code review', another stack exchange site. –Charles Green Jun 19 '14 at 16:19 Thanks for the tip, I added that site to my favorites and will turn to it for future scripting issues unless they might benefit the general user. –WxPilot Jun 19 '14 at 16:25 @CharlesGreen No way. CR says clearly: "However, if your question is ... about ... Trouble-shooting, debugging, or understanding code snippets ... then your question is off-topic for this site". Btw., CR is a young beta site with hardly anyone wasting their time there. –maaartinus Jun 19 '14 at 19:38 @maaartinus Crud - I thought since it said 'peer review' that it would be filled with people trying to figure out how to write code effectively. How about 'stack overf