Bin/sh 1 Syntax Error End Of File Unexpected
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the
Syntax Error End Of File Unexpected (expecting Fi )
workings and policies of this site About Us Learn more about Stack syntax error end of file unexpected (expecting done ) Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions
Syntax Error End Of File Unexpected (expecting Then )
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 each other. Join syntax error unexpected end of file in linux 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 at the line whee the function is called. #!/bin/sh expected_diskusage="264" syntax error unexpected end of file in unix shell script 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 connections wwwconn=`netstat -an|grep 80|wc -l` #www connections echo "Disk usage is $disk_usage" >> /tmp/alert.txt echo "DB connections $db_connections" >> /tm
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 In Php
Discuss the workings and policies of this site About Us Learn syntax error unexpected end of file bash more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack
Syntax Error Unexpected End Of File Shell Script
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, http://stackoverflow.com/questions/9886268/shell-script-syntax-error-unexpected-end-of-file helping each other. Join them; it only takes a minute: Sign up /bin/sh: 1: Syntax error: end of file unexpected (expecting “)”) up vote 1 down vote favorite mysqldump -u user -pPassword databasename | gzip > /home/sandra/backup/databasename-$(date +%Y-%m-%d-%H.%M.%S).sql.gz this executes correctly in a shell, but when put into crontab it generates error: /bin/sh: 1: Syntax error: end http://stackoverflow.com/questions/33569286/bin-sh-1-syntax-error-end-of-file-unexpected-expecting of file unexpected (expecting ")") any ideas what am i doing wrong? Thank you. crontab mysqldump share|improve this question asked Nov 6 '15 at 14:42 Sandra Johansson 154 stupid question here: does your password have a '(' in it? –Andrea Carron Nov 6 '15 at 14:48 nope only letters and numbers, i did copy paste the text from notepad++ into the shell though, could that add some unexpected things? –Sandra Johansson Nov 6 '15 at 14:50 Try to replace the $(date...) with the back ticks form date.... It may happen that the user shell is different from the shell used by cron or by the script itself. –Andrea Carron Nov 6 '15 at 14:52 that changed the error : /bin/sh: 1: Syntax error: EOF in backquote substitution –Sandra Johansson Nov 6 '15 at 15:33 2 solved by escaping % with \ –Sandra Johansson Nov 6 '15 at 15:42 add a comment| active oldest votes Know someone who can answer? Share a
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 http://unix.stackexchange.com/questions/84348/unexpected-end-of-file-error-when-executing-script About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads 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 up Here's how it works: Anybody can syntax error ask a question Anybody can answer The best answers are voted up and rise to the top Unexpected end of file error when executing script up vote 0 down vote favorite Can somebody help me debug this simple script. Been trying for 2 hrs now but I cant seem to get it to work. #!/bin/bash echo "Search for MMSC or WAP connectivity errors" sftpErrorCount=$(tail -100 3_ERRORs_log.txt | end of file grep "MMSC_Upload2" | grep "Fail to copy"| awk '{print $1 " " $2" " $3" " $4}'| wc -l) if [ "$sftpErrorCount" -gt 0 ] then sftpErrorDate=$(tail -100 3_ERRORs_log.txt | grep "MMSC_Upload2" | grep "Fail to copy"| awk '{print $1 " " $2" " $3" " $4}'| tail -1) echo "Error found at around $sftpErrorDate please check FTP logs" else echo "No errors found" Error when I execute the script sh test_script.sh Search for MMSC or WAP connectivity errors test_script.sh: line 14: syntax error: unexpected end of file linux bash share|improve this question asked Jul 25 '13 at 1:47 dimas 3191721 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted You need to close your if-statement with the word fi. #!/bin/bash echo "Search for MMSC or WAP connectivity errors" sftpErrorCount=$(tail -100 3_ERRORs_log.txt | grep "MMSC_Upload2" | grep "Fail to copy"| awk '{print $1 " " $2" " $3" " $4}'| wc -l) if [ "$sftpErrorCount" -gt 0 ] ; then sftpErrorDate=$(tail -100 3_ERRORs_log.txt | grep "MMSC_Upload2" | grep "Fail to copy"| awk '{print $1 " " $2" " $3" " $4}'| tail -1) echo "Error found at around $sftpErrorDate please check FTP l