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

Syntax Error Unexpected End Of File Shell Script


This is often incorrect, as we have seen. Put fi on a line of its own (or put a ; before it). [ "$3" < 50 ] is the same as [ "$3" ] < 50 — it's the Frequently, you will do this to a block of code to see if a particular problem goes away. After the first input, the unexpected-end-of-file error points to line #37 . . . Source

For example this scripts works ok: echo "hello" it prints "hello" with no errors. What the shell was trying to tell us was that there was only one item and there should have been a unary operator (like "!") that only operates on a single Not the answer you're looking for? I mean, If I put the number 13 it just ends, it doesn't say "Creo que esto ya no es un mes!" –Divshah Sep 12 '14 at 4:24 @Divshah:

Syntax Error Unexpected End Of File Shell Script

The loop it looks ok. –Radu Rădeanu Sep 3 '13 at 8:32 I run it with the sh command: sh script.sh –user568021 Sep 3 '13 at 8:36 colucix, thanks for your corroboration and the link. You are currently viewing LQ as a guest. Remnants of the dual number Grass grows through the floor of my building Close current window shortcut How do I reassure myself that I am a worthy candidate for a tenure-track

nc -z $Host $Port; then (or nc -z $Host $Port; result_nc=$? Should a country name in a country selection list be the country's local name? Plus and Times, Ones and Nines Change syntax of macro, to go inside braces more hot questions question feed lang-sh about us tour help blog chat data legal privacy policy work Syntax Error Unexpected End Of Input Nobody Dec 30 '15 at 16:56 add a comment| 2 Answers 2 active oldest votes up vote 4 down vote accepted You need to end every if statement with fi, like

measurable linear functionals are also continuous on separable Banach spaces? Syntax Error, Unexpected End Of File Php Why would a NES game use an undocumented 1-byte or 2-byte NOP in production? 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 innocent-looking snippet will cause the same error: die () { test -n "[email protected]" && echo "[email protected]"; exit 1 } To make the dumb parser happy: die () { test -n

David the H. Syntax Error Near Unexpected Token `fi' Last edited by T3RM1NVT0R; 12-30-2011 at 01:12 PM. Thanks! –user55570 Jun 17 '15 at 22:35 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign Finally, where are all your closing `fi`'s?

Syntax Error, Unexpected End Of File Php

Are you new to LinuxQuestions.org? T3RM1NVT0R View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by T3RM1NVT0R 12-28-2011, 03:11 PM #4 colucix LQ Guru Registered: Sep 2003 Location: Syntax Error Unexpected End Of File Shell Script The single bracket construct is an ordinary built-in command, so special characters such as < retain their normal meaning. Bash Unexpected End Of File While Looking For Matching if you actually need to store the exit code for some reason).

I am trying to put together a script (see below) that will backup data to a removable HHD by date. http://netlookmag.com/syntax-error/syntax-error-near-unexpected-token-then-39-in-shell-script.html Type y or n and press [ENTER]" read answer1 if [[ $answer1 == "N" || $answer1 == "n" ]]; then echo "Goodbye" -t 5 elif [[ $answer1 == "Y" || $answer more hot questions default about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation Science Other I'm not in a position to test right now, so there might not be anything wrong with yours - I am just not sure. Syntax Error Unexpected End Of File In Unix

Browse other questions tagged bash syntax or ask your own question. To the shell, this looks like three assignments that apply to the command fi. 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 have a peek here You will sometimes want to set a variable's value to nothing.

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 Bash Syntax Checker Bash Hot Network Questions Is it a coincidence that the first 4 bytes of a PGP/GPG file are ellipsis, smile, female sign and a heart? im not exactly sure where the code goes wrong –markcruz Jun 16 '11 at 2:43 weird, i cut and pasted your code and it worked as expected.

only there is no line #37.

all of you are right. I had a cat > temp.txt < EOF some content EOF The issue was that i copied the above code to be in a function and inadvertently tabbed the code. SEE YOU NEXT TIME!" Last edited by colucix; 12-28-2011 at 03:06 PM. Integer Expression Expected How to reward good players, in order to teach other players by example Why is bench pressing your bodyweight harder than doing a pushup?

Type y or n and press [ENTER]" -t 10 read answer2 if [[ $answer2 == "N" || $answer2 == "n" ]]; then echo "Goodbye" -t 5 else if [[ $answer2 == 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. It's pretty hard to understand the code like this. Check This Out But, sometimes even though every syntax is correct, you may still get this error.

How to construct a 3D 10-sided Die (Pentagonal trapezohedron) and Spin to a face? Why do the Avengers have bad radio discipline? Join them; it only takes a minute: Sign up Bash syntax error: unexpected end of file up vote 30 down vote favorite 14 Forgive me for this is a very simple I set the permissions to 777 and +x so it should work with the 'sh' command, right...

code tags preserve all whitespace and formatting, and display the data in a nice monospace font. Unable to complete a task at work. What did you say? UNIX is a registered trademark of The Open Group.

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. You could also try splitting the condition into two: if [ $# -lt 3 ] || [ $# -gt 3 ]; then echo "Error... Thanks again to all. if [[ -d ~/recovered-trash ]]; then mkdir ~/recovered-trash cp ~/TRASH.tar recovered-trash tar -xf ~/recovered-trash/TRASH.tar rm ~/recovered-trash/TRASH.tar #remove the copy echo "trash file extracted to ~/recovered-trash" else echo "no trash file found