Csh 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 syntax error unexpected end of file php Learn more about hiring developers or posting ads with us Unix & Linux Questions Tags syntax error unexpected end of file bash Users Badges Unanswered Ask Question _ Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and syntax error unexpected end of file wordpress 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 syntax error: unexpected syntax error unexpected end of file bash script end of file up vote 2 down vote favorite #!/bin/csh -f set no=1460 while ("$no">0) if [$no>900]; then set m=3 else if ["$no">450 && "$no"<901]; then set m=2 else set m=1 fi mv *$no.bin test/abc-$m-$no.bin set no =$no-1 end I'm a newbie to shell scripts. I'm trying to rename 1460 files using a csh script, but I get a syntax error "syntax error: unexpected end of file" I'm on tcsh shell. I've tried both fi and end
Syntax Error Unexpected End Of File Shell Script
to end the if condition. I get the same error. shell-script tcsh csh share|improve this question edited May 26 '14 at 6:42 Anthon 47.4k1462125 asked May 26 '14 at 6:38 user68580 1112 Try endif instead of fi? I'm a beginner too. Make sure you check this amazing document. –Faʁdɔʃɔtɔmatabaʁwɛt May 26 '14 at 8:20 3 There's no point whatsoever trying to learn csh in this millennium. Your system, if it is less than 20 years old will have a POSIX shell, at least a Bourne-like shell if it's less than 30 years old. Use that instead. –Stéphane Chazelas May 26 '14 at 8:54 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote A quick Google search reveals that your IF statement syntax is probably incorrect. You may be mixing syntax from another shell. if ( $no > 900 ) then set m=3 else if ( $no > 450 && $no < 901) set m=2 else set m=1 endif http://beefchunk.com/documentation/tips/unix_tips_and_tricks/node40.html share|improve this answer answered May 26 '14 at 10:41 kwarrick 1,71868 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the priv
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies
Syntax Error Unexpected End Of File Python
of this site About Us Learn more about Stack Overflow the company Business syntax error unexpected end of file unix Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges syntax error unexpected end of file laravel 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; it only takes a minute: http://unix.stackexchange.com/questions/131997/syntax-error-unexpected-end-of-file 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 http://stackoverflow.com/questions/9886268/shell-script-syntax-error-unexpected-end-of-file -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 Stack Overflow the company Business Learn more about hiring developers http://stackoverflow.com/questions/10431757/if-statement-throws-unexpected-end-of-file-in-shell-script or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x http://forum.codecall.net/topic/74335-csh-unexpected-end-of-file/ Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up If statement throws unexpected end of file in shell script up vote 0 down vote favorite Whenever I run this script the find part executes but the if statement causes this error: ./list_datasheets.csh: line syntax error 13: syntax error: unexpected end of file this is the script: find $1 -type d | while read -r dir do for f in ${dir}/* do echo ${f} | tr '[A-Z]' '[a-z]' done done if ($2 == "both") then echo 'bye' else echo 'hi' endif linux bash shell share|improve this question asked May 3 '12 at 12:50 Joe Hart 2117 that's not bash... –KurzedMetal May 3 '12 at 12:53 add a comment| 2 Answers 2 active oldest votes syntax error unexpected up vote 9 down vote accepted Try replacing the last line (endif) with fi, which is the correct token to close an if statement. Also, replace ($2 == "both") with the correct [ $2 == "both" ]. Oh, and then, actually the if should be written as: if [ "$2" == "both" ]; then echo 'bye' else echo 'hi' fi Note the quotes around $2, the spaces after [ and before ] and the ; before the then. share|improve this answer edited May 3 '12 at 14:20 glenn jackman 121k1782162 answered May 3 '12 at 12:52 Christian.K 28.1k54774 That solved that problem now i get the error line 8: both:command not found –Joe Hart May 3 '12 at 13:10 Got it working, thanks for the help :) –Joe Hart May 3 '12 at 13:13 add a comment| up vote 2 down vote You need to end the if block with a fi and not endif. I guess you got confused with the #endif way of closing the #if block in C and C++. share|improve this answer answered May 3 '12 at 12:52 codaddict 250k50362442 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the pr
Programming C# C and C++ Java Pascal and Delphi Visual Basic Perl Python Assembly Bash / Shell Scripting Mobile Development Game Development Web Development General Discussions PHP ASP.NET ASP Ruby Databases HTML5 / HTML / XHTML / DHTML CSS / CSS3 JavaScript / jQuery / AJAX / JSON ColdFusion Website Design Tutorials Submit Tutorial Assembly C and C++ C# Database HTML, CSS and JavaScript Java PHP Python Visual Basic Game Development Mobile Development Other Tutorials Community Search Site Members Lounge Introduce Yourself Image Gallery Facebook Twitter YouTube Guidelines FAQ Help Blogs Gallery Unanswered Join Codecall.net Why Join Codecall? Register with Facebook Register with Twitter Android Cheats More Codecall → General Forums → General Computing → Linux Javascript Disabled Detected You currently have javascript disabled. Several functions may not work. Please re-enable javascript to access full functionality. Check out our Community Blogs Recent Topics Simple while loop, i mean really simple and i cant do it :( Siten0308 - Yesterday, 11:54 AM HostForLIFE.eu – Cheap Windows & ASP.NET Core 1.0.1 hosting EUWindowsHost - Oct 03 2016 12:38 AM Jigsaw Puzzle Website Content Packs - Add jigsaw puzzles to your website Zethix - Sep 28 2016 04:20 PM Tools for Feature Flighting/Flagging and A/B Testing anujanand - Sep 26 2016 04:28 PM Mosquito net chennai | Phiferindia mosquitonetchennai - Sep 23 2016 04:05 AM Recent Blog Entries Remove Characters in String T-SQL with No Loop Part 2 Barnsite's Blog 09 May Remove Characters in String T-SQL with No Loop Barnsite's Blog 09 May Black hat hacking DarkLordofthePenguins's Blog 05 Nov Essential skills for computer nerds DarkLordofthePenguins's Blog 11 Sep Adventures in VirtualBox DarkLordofthePenguins's Blog 22 Jul Recent Status Updates · Unlock · Lock 03 Sep surajkumardotin Student college project Hide Comments · Unlock · Lock 25 Jun TopHatProductions115 The TXP-Network is coming back this July... Hide Comments · Unlock · Lock 12 Feb moonvik Java... Hide Comments · Unlock · Lock 04 Feb camD357 I love this community ! Hide Comments · Unlock · Lock 02 Jan