Linux Script 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 bash unexpected end of file while looking for matching of this site About Us Learn more about Stack Overflow the company Business
Syntax Error Unexpected End Of Input
Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges shell script validator Ask 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: syntax error near unexpected token `fi' 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 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
Syntax Error Near Unexpected Token `done'
-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 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=============
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 syntax error unexpected end of file python Stack Overflow the company Business Learn more about hiring developers or posting ads with integer expression expected us Unix & Linux Questions Tags Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and
Unary Operator Expected Bash
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 answers http://stackoverflow.com/questions/9886268/shell-script-syntax-error-unexpected-end-of-file 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 #Primero debes http://unix.stackexchange.com/questions/155166/got-syntax-error-near-unexpected-end-of-file-in-bash-script 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, sigamos." else if [
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 http://askubuntu.com/questions/145900/syntax-error-unexpected-end-of-file-simple-script 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 syntax error answer The best answers are voted up and rise to the top “syntax error: unexpected end of file” simple script up vote 1 down vote favorite i need some help for a very siple script, i don't get were the fault is. The script : #!/bin/bash declare -i s declare -i m declare -i h if [ "$3" < 50 ]; then s=$3+10 m=$2 h=$1 else unexpected end of if ["$2" < 50 ]; then s=$3-50 m=$2+1 h=$1 else s=$1-50 m=$2-50 h=$1+1 fi fi echo "$h:$m:$s" The script add 10sc to the time we've entered. I get this error message : "sub_change_dirrect: line 14: syntax error: unexpected end of file" bash scripts share|improve this question edited Jun 3 '12 at 12:54 adempewolff 5,69011943 asked Jun 3 '12 at 12:41 Sam 4494915 add a comment| 2 Answers 2 active oldest votes up vote 2 down vote accepted There are three obvious errors: On the line else s=$1-50 m=$2-50 h=$1+1 fi, the word fi is not treated as a keyword, because it is not the first word in the command. To the shell, this looks like three assignments that apply to the command fi. If you ever got to execute this line, you'd see an error bash: fi: command not found. Put fi on a line of its own (or put a ; before it). [ "$3" < 50 ] is the same as [ "$3" ] < 50 — it's the command [ … ] (which can also be written test) with the sole argument "$3", and with an input redirection from the