Line 43 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 syntax error unexpected end of file php this site About Us Learn more about Stack Overflow the company Business
Syntax Error: Unexpected End Of File Bash
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask
Bash Unexpected End Of File While Looking For Matching
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 them; it only takes a minute: Sign up
Syntax Error Unexpected End Of Input
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 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 syntax error at line (' unexpected 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 connections wwwconn=`netstat -an|grep 80|wc -l` #www connections echo "Disk usage is $disk_usage" >> /tmp/alert.txt echo "DB connections $db_connections" >> /tmp/alert.txt echo "Network connections $nwconn" >> /tmp/alert.txt echo "CPU Usage: $cpu_usage" >> /tmp/alert.txt topsnapshot=`top -n 1 -b` echo "===========================TOP COMMAND SNAPSHOT===================================================="; echo "$topsnapshot" >> /tmp/ale
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 java syntax error: end of file unexpected (expecting ")") posting ads with us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix shell script validator & 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 syntax error unexpected end of file python 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 [closed] up vote 0 down vote http://stackoverflow.com/questions/9886268/shell-script-syntax-error-unexpected-end-of-file favorite 1 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 http://unix.stackexchange.com/questions/193165/syntax-error-unexpected-end-of-file-bash-script --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 shell-script share|improve this question edited Mar 29 '15 at 5:19 Anthon 47.6k1462125 asked Mar 29 '15 at 1:31 Scott Pearce 46117 closed as unclear what you're asking by mdpc, jasonwryan, Networker, Michael Homer, Archemar Mar 29 '15 at 8:23 Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question. (0) It might have been more useful to show us a diff from the last version that worked. … … … … … … … … Some observations (that probably don’t relate to your current, specific problem): (1) I don’t know of any circumstance where you need an unescaped ; (semicolon) at the end of a line. You can delete the semicolons at the ends of lines 157, 161, 165, 168, and 169. (Or you can leave them in; I guess it’s a question of style.) … (Cont’d) –Scott Ma
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 http://askubuntu.com/questions/485567/unexpected-end-of-file more about hiring developers or posting ads with us Ask Ubuntu Questions Tags Users Badges http://linuxcommand.org/wss0100.php 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 syntax error 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 = unexpected end of 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 overflow'? –Charles Green Jun 19 '14 at 22:00 1 @CharlesGreen It's jus
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. 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 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 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 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 substituted 1 for $number like so: if [ 1 = "1" ]; then However, when we set number to nothing (number=), the shell saw this after the substitution: if [ = "1" ]; then which is an error. It also explains the rest of the error message we received. The "=