Make 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 java syntax error: end of file unexpected (expecting ")") Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs syntax error unexpected end of file shell script Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just syntax error: unexpected end of file bash like you, helping each other. Join them; it only takes a minute: Sign up Syntax error : end of file unexpected (expecting “fi”) up vote 7 down vote favorite 1 I am writing a makefile in bash
Unexpected Expecting Fi
and I have a target in which I try to find if a file exists and even though I think the syntax is correct, i still gives me an error. Here is the script that I am trying to run read: if [ -e testFile] ; then \ cat testFile\ fi I am using tabs so that is not a problem. The error is (when I type in: "make read") if [ -e testFile] ; syntax error: "fi" unexpected (expecting then \ cat testFile \ fi /bin/sh: Syntax error: end of file unexpected (expecting "fi") make: *** [read] Error 2 bash makefile share|improve this question edited Apr 24 '09 at 19:26 ephemient 118k26178303 asked Apr 19 '09 at 5:48 Jaelebi 1,46362129 add a comment| 3 Answers 3 active oldest votes up vote 11 down vote accepted Try adding a semicolon after cat testFile. For example: read: if [ -e testFile ] ; then cat testFile ; fi alternatively: read: test -r testFile && cat testFile share|improve this answer edited Mar 25 '11 at 23:42 Julien Roncaglia 12.5k13667 answered Apr 19 '09 at 6:01 jwa 16113 1 the alternate solution works but I have to use the if..then syntax. adding a semicolon does not seem to solve the issue. –Jaelebi Apr 19 '09 at 6:09 Weird. I tried it the first time with semicolon and it didnt work. th second time I ran it it worked.Thanks –Jaelebi Apr 19 '09 at 6:14 Just a note to self: I originally wrote plain multiline bash statements in the makefile, and had the same failure - and as this answer notes, the trick is to have the makefile recognize the shell command as a single line; hence I'd need both semicolon ; (to separate shell commands) and backslash `\` (to
here for a quick overview of the site Help Center Detailed answers to any questions you might have syntax error unexpected end of input Meta Discuss the workings and policies of this site About Us
Bash Unexpected End Of File While Looking For Matching
Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with
Syntax Error Unexpected Expecting Fi Ubuntu
us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, http://stackoverflow.com/questions/764908/syntax-error-end-of-file-unexpected-expecting-fi just like you, helping each other. Join them; it only takes a minute: Sign up Shell Script Syntax Error: Unexpected End of File up vote 8 down vote favorite 2 In the following script I get an error: syntax error: unexpected end of file What is this error how can I resove it? It is pointing http://stackoverflow.com/questions/9886268/shell-script-syntax-error-unexpected-end-of-file at the line whee the function is called. #!/bin/sh expected_diskusage="264" expected_dbconn="25" expected_httpdconn="20" expected_cpuusage="95" #expected_fd="100" httpdconn=`ps -ef|grep -i httpd|grep -v grep|wc -l` #httpd connections cpu_usage=`ps aux|awk 'NR > 0 { s +=$3 }; END {print s}'` disk_usage=`df -h|awk {'print $2'}|head -n3|awk 'NF{s=$0}END{print s}'` #db_connections=`mysql -uroot -pexxxxxx -s -N -e "show processlist"|wc -l` db_connections=6 cld_alert() { nwconn=$1 cpu_usage=$2 disk_usage=$3 db_connections=$4 message=$5 `touch /tmp/alert.txt && > /tmp/alert.txt` date=`date` echo -e "$date\n" > /tmp/alert.txt echo -e "$message" >> /tmp/alert.txt path="/proc/$httpd/fd/"; cd $path tfd=`ls -l|wc -l`; sfd=`ls -ltr|grep sock|wc -l`; echo "Total fds: $tfd" >> /tmp/alert.txt echo "Socket fds: $sfd" >> /tmp/alert.txt echo "Other fds: $[$tfd - $sfd]" >> /tmp/alert.txt freememory=`vmstat | awk '{if (NR == 3) print "Free Memory:"\$4}'`; echo "Free memory :$freememory" >> /tmp/alert.txt Bufferedmemory=`vmstat | awk '{if (NR == 3) print "Buffered Memory:"\$5}'`; echo "Buffered memory $Bufferedmemory" >> /tmp/alert.txt CacheMemory=`vmstat | awk '{if (NR == 3) print "Cache Memory:"\$6}'`; echo "Cache memory : $CacheMemory" >> /tmp/alert.txt sshconn=`netstat -an|grep 22|wc -l` #ssh connections httpsconn=`netstat -an|grep 443|wc -l` #https connec
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 http://unix.stackexchange.com/questions/155166/got-syntax-error-near-unexpected-end-of-file-in-bash-script with us Unix & Linux 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. Join them; it only takes a minute: Sign http://askubuntu.com/questions/340767/unexpected-eof-in-a-bash-script-why 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 Got “syntax error near unexpected end of file” in bash script up vote 0 down vote favorite 2 I'm syntax error 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 #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 unexpected end of 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 72k13116201 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, sigamos." else if [ "$mes" -gt 12 -a "$mes" -lt 0 ]; then echo "Creo que eso ya no es un mes!" # Missed fi here fi exit fi share|improve this answer edited Dec 16 '14 at 10:34 answered Sep 12 '14 at 4:03 cuonglm 72k13116201 Thanks! That worked. –Divshah Sep 12 '14 at 4:23 Now I have another issue, it doesn't display the second if part... I mean, If I put the number 13 it just ends, it doesn't s
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 EOF in a bash script, why? 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") Is there something wrong with that loop? command-line bash scripts share|improve this question edited Sep 3 '13 at 21:57 Braiam 39.1k1693154 asked Sep 3 '13 at 8:29 user568021 3002619 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. &nda