Home > Syntax Error > Syntax Error: Unexpected End Of File Bash

Syntax Error: Unexpected End Of File Bash

Contents

These are the common things which just slip. Rebus: Guess this movie Will majority of population dismiss a video of fight between two supernatural beings? To fix this problem, change line 5 to read: if [ "$number" = "1" ]; then Now when the shell performs the substitution it will see: if [ "" = "1" Remember that the shell spends a lot of its life substituting text. Source

In the latter part of your code, you have 5 ifs and 4 fis. 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 So what's wrong with line 5? And do check out http://www.shellcheck.net/ share|improve this answer edited Jun 17 '15 at 22:35 answered Jun 16 '15 at 20:19 user55570 22729 Also, the result_nc thing can be skipped

Syntax Error: Unexpected End Of File Bash

Is it unethical to take a photograph of my question sheets from a sit-down exam I've just finished if I am not allowed to take them home? Is it still safe to drive? You probably think that by removing the "1" on line 3 it created a syntax error on line 3, but it didn't. Can a creature with 0 power attack?

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 What are the advantages of doing accounting on your personal finances? I should have asked what editor you were using! Java Syntax Error: End Of File Unexpected (expecting ")") By doing this, you can isolate which part of a program is causing (or not causing) a problem.

To understand this error, we have to see what the shell sees. Bash Unexpected End Of File While Looking For Matching Square root image filter tool in Python Word for nemesis that does not refer to a person Secret salts; why do they slow down attacker more than they do me? To get that error message from bash for the command: set -xv, you must be using an editor that uses the DOS convention of carriage-return followed by newline as the line Ask Ubuntu works best with JavaScript enabled current community blog chat Server Fault Meta Server Fault your communities Sign up or log in to customize your list.

Not the answer you're looking for? Syntax Error Near Unexpected Token `fi' I haven't reviewed your logic. 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 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 if ["$2" < 50 ]; then s=$3-50

Bash Unexpected End Of File While Looking For Matching

It felt so wrong to have un-indented code in the block, but it's absolutely necessary. –Zeal Jul 6 at 17:50 add a comment| up vote 2 down vote echo"==================PS COMMAND SNAPSHOT==============================================================" How do I politely decline a research grant? Syntax Error: Unexpected End Of File Bash I strongly suggest that you look at the documentation for your editor to see if there is a way to set the characters used as line terminators. Syntax Error Unexpected End Of Input Browse other questions tagged shell sh or ask your own question.

We usually only see this problem on files that have been copied from Windows systems to UNIX and Linux systems. http://netlookmag.com/syntax-error/syntax-error-near-unexpected-token-newline-39-bash.html The first type simply announces that you have reached a certain point in the program. I'll also recommend shellcheck.net for basic sanity-checking. –Gordon Davisson Jun 17 '15 at 6:25 Updated the answers. Here is the last portion: #checks if speed is 150 157 if [[ $2 -eq 150 ]]; 158 then 159 starttime=$SECONDS 160 FS=$'\n' 161 for j in `grep --color=always -iP '\b[^aeiou\s]*[aeiou][^aeiou\s]*\K[aeiou]' Syntax Error At Line (' Unexpected

Join them; it only takes a minute: Sign up Shell Script Syntax Error: Unexpected End of File up vote 9 down vote favorite 3 In the following script I get an And at least 4 spaces per indentation level at that, so you can really see the structure. This is often incorrect, as we have seen. have a peek here How secure is a fingerprint sensor versus a standard password?

And remove the spaces in the assignment: Host = ############### Port = #### so that becomes: Host=############### Port=#### because assignments will not work properly if there are spaces. Shell Script Validator asked 3 years ago viewed 16948 times active 3 years ago Related 6How do the environments of a standard Terminal command-line and a bash script differ?14Problem with Bash script: 'declare: not Please find below whole script: Code: #!/bin/bash echo "=== Checking logs ===" returned=`tail -50 SapLogs.log | grep -i "Error"` echo $returned if [ -n "${returned}" ]; then echo "There is no

In this particular case, I can see you are missing a fi.

I set the permissions to 777 and +x so it should work with the 'sh' command, right... 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; So, I think you can get your script to work if you write this into a new file (let's call it newscript): Code: #!/bin/bash echo "=== Checking logs ===" tail -50 Unexpected Eof While Looking For Matching `"' Is it unethical to take a photograph of my question sheets from a sit-down exam I've just finished if I am not allowed to take them home?

Linux.org - Error A server error occurred. Is it unethical to take a photograph of my question sheets from a sit-down exam I've just finished if I am not allowed to take them home? more hot questions question feed lang-sh about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation http://netlookmag.com/syntax-error/syntax-error-near-unexpected-token-bash-function.html Than it work fine –shubham kumar Mishra Feb 12 '15 at 11:51 add a comment| up vote 0 down vote I have found that this is sometimes caused by running a

current community chat Stack Overflow Meta Stack Overflow your communities Sign up or log in to customize your list. Finding the desired way later means double work in such spaghetti code. I am writing it for first time. or recreate the script in linux iteself.

Help Forums Forums Quick Links Search Forums Recent Posts Resources Resources Quick Links Search Resources Most Active Authors Members Members Quick Links Notable Members Current Visitors Recent Activity New Profile Posts For example, when we were looking for our missing quotation we could have done this: #!/bin/bash number=1 if [ $number = "1" ]; then echo "Number equals 1 #else # echo This time you should get the following: [[email protected] me]$ ./trouble.bash /trouble.bash: [: =: unary operator expected. 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

This technique is called tracing. Empty variables Edit the script to change line 3 from: number=1 to: number= and run the script again. It is very strange that the output from the 1st script you showed us did not contain the line: Code: === Checking logs === Please add the following line to your How many times do you need to beat mom and Satan etc to 100% the game?

up vote 3 down vote favorite I can't normally run sh scripts. The ! Watching your script run It is possible to have bash show you what it is doing when you run your script. 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.

Why does MIT have a /8 IPv4 block? We saw this in our earlier discussion on stubbing.