Home > Syntax Error > Unix Shell Syntax Error Unexpected End Of File

Unix Shell Syntax Error Unexpected End Of File

Contents

more stack exchange 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 Browse other questions tagged bash shell-script or ask your own question. asked 2 years ago viewed 3825 times active 2 years ago Related -3Shell script- syntax error: unexpected end of file2syntax error: unexpected end of file-1syntax error: unexpected end of the file0unexpected asked 3 years ago viewed 16343 times active 3 years ago Related 6How do the environments of a standard Terminal command-line and a bash script differ?12Problem with Bash script: 'declare: not Check This Out

I did not get a syntax error. paulsm4 View Public Profile View LQ Blog View Review Entries View HCL Entries Visit paulsm4's homepage! Use echo commands to verify your assumptions. As Gordon suggested, change that to: if nc -z $Host $Port then ... see this here

Bash Unexpected End Of File While Looking For Matching

Does Nietzsche's rejection of Socrates mean that he is a relativist about ethics? I am confused, I have an if statement at last and it looks correct! 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 connections cpu_usage=`ps aux|awk 'NR > 0 Thank you in advance ..

Does the reciprocal of a probability represent anything? I think you want to replace the quotes in this line with backticks: result_nc='nc -z $Host $Port; echo $?' so change it to: result_nc=`nc -z $Host $Port; echo $?` There is more hot questions question feed lang-bsh about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation Syntax Error: End Of File Unexpected (expecting "then") They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.

Obviously, it's more different then coding then I thought. Please use the new version at LinuxCommand.org LinuxCommand Learningtheshell Writingshellscripts Script library SuperMan pages Who, What, Where, Why Tips, News And Rants Previous | Contents | Next Stay Out Of Trouble bash unix shell share|improve this question edited Jun 16 '15 at 20:09 krisFR 7,45621025 asked Jun 16 '15 at 20:03 Raghavendra 111 Is your script in DOS/Windows format (\r\n http://unix.stackexchange.com/questions/114138/shell-unexpected-end-of-file-error Browse other questions tagged bash scripts or ask your own question.

more stack exchange 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 Syntax Error Near Unexpected Token `fi' To combat this, you should place echo commands in your code while you are debugging, to produce messages that confirm the program is doing what is expected. Run the file ("./tmp.sh") with no arguments 6. You have to check that.

  1. Try changing it to #!/bin/bash catkin View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by catkin View Blog 04-29-2010, 12:43 PM #7
  2. Why were Navajo code talkers used during WW2?
  3. And please indent consistently. #!/bin/bash declare -i s declare -i m declare -i h if (( $3 < 50 )); then s=$3+10 m=$2 h=$1 elif (( $2 < 50 )); then
  4. nc -z $Host $Port; then (or nc -z $Host $Port; result_nc=$?
  5. It's most probably missing fi or } somewhere, but without indentation you won't ever see where. –Jan Hudec Mar 27 '12 at 9:17 What is the assignment to value
  6. Forum Operations by The UNIX and Linux Forums
  7. number= is perfectly good syntax.
  8. What object can prove the equations?
  9. I used heredoc inside an if block.

Syntax Error Unexpected End Of Input

How to select citizen justices? http://linuxcommand.org/wss0100.php What is way to eat rice with hands in front of westerners such that it doesn't appear to be yucky? Bash Unexpected End Of File While Looking For Matching Extraneous carriage returns in shell scripts, source code for other languages, and in data files will cause you no end of grief.

Remove advertisements Sponsored Links Don Cragun Shell Script Validator reverses it to 'if not': Code: if !

What to do when majority of the students do not bother to do peer grading assignment? his comment is here Here is what it looks like: [[email protected] me]$ ./trouble.bash + number=1 + '[' 1 = 1 ']' + echo 'Number equals 1' Number equals 1 Alternately, you can use the set What game is the guard playing in this picture? How strange is it (as an undergrad) to email a professor from another institution about possibly working in their lab? 2011 MacBook Pro upgrade? Syntax Error Unexpected End Of File Python

It worked before. What happens is the shell keeps looking for the closing quotation mark to tell it where the end of the string is, but runs into the end of the file before What are the German equivalents of “First World War”, “World War I”, and “WWI”? this contact form From this we can determine that the error is occurring on line 5 not line 3.

Use code blocks (the "#" symbol on the LQ toolbar). Delimited By End-of-file (wanted `eof') I set the permissions to 777 and +x so it should work with the 'sh' command, right... 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:

This site is not affiliated with Linus Torvalds or The Open Group in any way.

I will continue working that way from now on. I don't see why the following would make any difference in the behavior of your script (except that if there are multiple errors found, they will be printed on separate lines; Number sets symbols in LaTeX Before I leave my company, should I delete software I wrote during my free time? Syntax Error Near Unexpected Token `done' more stack exchange 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

This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. Regards, Adrian Remove advertisements Sponsored Links jedzio View Public Profile Find all posts by jedzio #2 07-31-2014 Don Cragun Administrator Join Date: Jul 2012 In order to become a pilot, should an individual have an above average mathematical ability? navigate here How can I make two cutting lines close to each other?

These errors can be a real pain to find in a long script. This brings up an important thing to remember when you are writing your scripts. By doing this, you can isolate which part of a program is causing (or not causing) a problem. The first type simply announces that you have reached a certain point in the program.

Who was Mikael Blomkvist with at the end of the movie and why did Lisbeth hate it so much? If that's the case dos2ux should fix that. How do I handle an unterminated wire behind my wall? AWS EC2 SSH from my IP address which has changed Why can't the second fundamental theorem of calculus be proved in just two lines?

reverses it to 'if not': Code: if ! Why does Wikipedia list an improper pronunciation of Esperanto? I haven't reviewed your logic. My first comment would be that you should change: Code: echo $returned to: Code: echo "$returned" or better yet (removing problems that could be caused depending on the contents of SapLogs.log):

Unix & Linux Stack Exchange works best with JavaScript enabled current community chat Unix & Linux Unix & Linux Meta your communities Sign up or log in to customize your list. Why cast an A-lister for Groot? Ask Ubuntu works best with JavaScript enabled UbuntuCommunityAsk!DeveloperDesignDiscourseHardwareInsightsJujuShopMore ›AppsHelpForumLaunchpadMAASCanonical current community chat Ask Ubuntu Ask Ubuntu Meta your communities Sign up or log in to customize your list. Solutions?

In this particular case, I can see you are missing a fi. To do this, add a "-x" to the first line of your script, like this: #!/bin/bash -x Now, when you run your script, bash will display each line (with substitutions performed) Consider what happens if a variable is set to equal nothing. Missing quotes Edit line 6 to remove the trailing quote from the end of the line: echo "Number equals 1 and run the script again.

We don't want the > /dev/null here because this code is replacing earlier code that was: Code: returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned and then checking whether "$returned"