Cygwin Sh Syntax Error Unexpected End Of File
Contents |
Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here. Search Forums Show Threads Show Posts Tag Search Advanced Search sh c line 1 syntax error unexpected end of file Unanswered Threads Find All Thanked Posts Go to Page... learn unix and linux syntax error unexpected end of file php commands cygwin syntax error: unexpected end of file Shell Programming and Scripting Thread Tools Search syntax error unexpected end of file bash this Thread Display Modes #1 07-14-2012 ranjancom2000 Registered User Join Date: Apr 2011 Last Activity: 9 February 2016, 9:01 AM EST Posts: 65 Thanks: 0 Thanked 0 Times in 0
Syntax Error Unexpected End Of File Wordpress
Posts cygwin syntax error: unexpected end of file Hi, I am getting error while running the script. "syntax error: unexpected end of file" if i do cat i cant see the content of the script also it is showing as HTML Code: cat test.sh doner /home/master/* /home/Priya/$i| while read i j The original script is Code: paste /home/names.txt /home/ip.txt | while read i j do mkdir $i cp -r /home/master/* syntax error unexpected end of file bash script /home/test/$i done Remove advertisements Sponsored Links ranjancom2000 View Public Profile Find all posts by ranjancom2000 #2 07-14-2012 alister Registered User Join Date: Dec 2009 Last Activity: 11 June 2014, 8:40 PM EDT Posts: 3,231 Thanks: 179 Thanked 976 Times in 790 Posts Looks like your script's "lines" are terminated by carriage returns instead of line feeds. Regards, Alister Remove advertisements Sponsored Links alister View Public Profile Find all posts by alister #3 07-14-2012 ranjancom2000 Registered User Join Date: Apr 2011 Last Activity: 9 February 2016, 9:01 AM EST Posts: 65 Thanks: 0 Thanked 0 Times in 0 Posts How i can remove the "carriage returns" ranjancom2000 View Public Profile Find all posts by ranjancom2000 #4 07-14-2012 Tribe Registered User Join Date: Jul 2012 Last Activity: 1 October 2016, 7:52 AM EDT Posts: 52 Thanks: 44 Thanked 4 Times in 4 Posts Could you try converting from windows format to unix format? Code: tr -d '\15\32' < winfile.sh > unixfile.sh More info on kb.iu.edu/data/acux.html Last edited by Tribe; 07-14-2012 at 05:00 AM.. Remove advertisements Sponsored Links Tribe View Public Profile Find all posts by Tribe #5 07-14-2012 alister Registe
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings syntax error unexpected end of file shell script and policies of this site About Us Learn more about Stack
Syntax Error Unexpected End Of File Python
Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs
Syntax Error Unexpected End Of File Unix
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 them; http://www.unix.com/shell-programming-and-scripting/193609-cygwin-syntax-error-unexpected-end-file.html 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" expected_dbconn="25" expected_httpdconn="20" http://stackoverflow.com/questions/9886268/shell-script-syntax-error-unexpected-end-of-file 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" >> /tmp/alert.txt echo "Network connections $nwc
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 http://stackoverflow.com/questions/31216532/syntax-error-unexpected-end-of-file-trying-to-run-a-simple-bash-script Business Learn more about hiring developers or posting ads with us Stack 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 http://unix.stackexchange.com/questions/114138/shell-unexpected-end-of-file-error like you, helping each other. Join them; it only takes a minute: Sign up syntax error: unexpected end of file trying to run a simple bash script up vote 1 down vote favorite I really can't see syntax error what the issue is with my script is. I've considered missing quotations or other syntax errors. There's got to be something I'm missing. It's a very simple while loop script... #!/bin/bash c=1 while [ $c -le 5 ] do echo "Welcone $c times" c=$(( c++ )) done I should mention that I'm running bash in cygwin on windows 7. thanks for the help bash cygwin eof share|improve this question asked Jul 4 '15 at syntax error unexpected 3:14 user3671613 1315 Could it be a strange Windows whitespace character? I tried running it in Linux and got the following output. –Huey Jul 4 '15 at 3:18 Did you use a windows editor (like Notepad) to create this file? If so, you've probably got end-of-line problems. Try using dos2unix to convert it (and read the man page, it overwrites its input). –bishop Jul 4 '15 at 3:24 probably is. I guess I just wont think about it too much and I'll try running it in linux when I can. (I can't install dos2unix in windows with sudo apt-get apparently... if you have a workaround I'd appreciate it ^ ^) –user3671613 Jul 4 '15 at 3:29 Use Notepad++ on windows. It has a setting for line endings (and syntax highlighting, etc). –ooga Jul 4 '15 at 3:31 tr -d '\r' < your-script.sh > temp.sh; mv temp.sh your-script.sh –anishsane Jul 4 '15 at 3:52 | show 1 more comment 1 Answer 1 active oldest votes up vote 0 down vote Change: c=$(( c++ )) to (( c=c+1 )) When Bash sees: (( var)) it will try and 'do some math' on contents... In this case 'c++' == empty string == '0'; c will always be equal to '1' due to 1st assignment...
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 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 ask a question Anybody can answer The best answers are voted up and rise to the top shell unexpected end of file error up vote 0 down vote favorite I had the below script working in a linux machine. page="$(curl http://www.google.com/| grep "title")" if [ -z "$page" ]; then echo "Empty page" else echo "Valid page" fi When am running in another machine, I am getting the error syntax error: unexpected end of file. Why am getting this error? shell shell-script share|improve this question asked Feb 8 '14 at 2:31 Ramesh 15.9k1674124 1 What are the machines? You have to watch for differences in the various shells. –slm♦ Feb 8 '14 at 3:48 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted You probably have invisible CR characters at the end of your lines (like when the file is in Microsoft format where the lines are terminated by the CRLF sequence of characters instead of just LF). Then, the shell complains that it reaches the end of the script file without finding a then following the if (there's just a then