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

Syntax Error Unexpected End Of File Shell Script

Contents

if you actually need to store the exit code for some reason). To do this, create the following script called trouble.bash. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Should a country name in a country selection list be the country's local name? his comment is here

The single bracket construct is an ordinary built-in command, so special characters such as < retain their normal meaning. 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 Here's the code: #!/bin/bash # june 2011 if [ $# -lt 3 -o $# -gt 3 ]; then echo "Error... Why does Snoke not cover his face?

Syntax Error Unexpected End Of File Shell Script

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. 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 The line number pointing to the end of the script is not helpful in this case, beyond saying to inspect your syntactical constructs; the error may be anywhere in your code. After the first input, the unexpected-end-of-file error points to line #37 . . .

A simple it didn't work for me suffices. As for the quotes . . . 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. Syntax Error Unexpected End Of Input Nobody 235 add a comment| Not the answer you're looking for?

Use echo commands to verify your assumptions. colucix View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by colucix 12-28-2011, 05:48 PM #5 David the H. Is an internal HDD with Ubuntu automatically bootable from an external USB case? 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

more hot questions question feed default 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 Near Unexpected Token `fi' colucix View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by colucix 12-30-2011, 12:13 PM #9 smecnb LQ Newbie Registered: Dec 2011 Posts: They do not preserve formatting in any way. How should I tell my employer?

Syntax Error, Unexpected End Of File Php

Display a Digital Clock Why does Davy Jones not want his heart around him? The main problem of your code is that there is no fi keyword to close the if/then/else constructs, hence the unexpected end error! Syntax Error Unexpected End Of File Shell Script Nobody Dec 26 '15 at 15:57 @Mr.Nobody if this answers your question, don't forget to mark it accepted –janos Dec 29 '15 at 7:04 Don't think down Bash Unexpected End Of File While Looking For Matching command-line bash share|improve this question edited Dec 20 '15 at 4:45 asked Dec 20 '15 at 4:40 Blacksilver 1073 i haven't done --setup yet, FYI. –Blacksilver Dec 20 '15

As Gordon suggested, change that to: if nc -z $Host $Port then ... this content 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 For any doubt about the advertising policy, feel free to contact the LQ administrator, using this form: http://www.linuxquestions.org/questions/sendmessage.php. nc -z $Host $Port; then (or nc -z $Host $Port; result_nc=$? Syntax Error Unexpected End Of File In Unix

Bash Guru Registered: Jun 2004 Location: Osaka, Japan Distribution: Debian sid + kde 3.5 & 4.4 Posts: 6,823 Rep: The OP has fixed it now, but the script was originally Last edited by zQUEz; 12-28-2011 at 02:45 PM. 1 members found this post helpful. Visit the following links: Site Howto | Site FAQ | Sitemap | Register Now If you have any problems with the registration process or your account login, please contact us. http://mmonoplayer.com/syntax-error/syntax-error-near-unexpected-token-shell-script.html 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

Please only use [code][/code] tags around your code and data. Bash Syntax Checker UbuntuCommunityAsk!DeveloperDesignDiscourseHardwareInsightsJujuShopMore ›AppsHelpForumLaunchpadMAASCanonical current community chat Ask Ubuntu Ask Ubuntu Meta your communities Sign up or log in to customize your list. That's why SO allowed multiple answers to a question because there can be multiple solutions to a problem. –Jeff Wilbert Jul 27 '15 at 15:33 | show 2 more comments up

Sorry.

Please visit this page to clear all LQ-related cookies. Nobody Dec 30 '15 at 16:41 add a comment| up vote 1 down vote UPDATED SCRIPT (WORKING) #!/bin/bash clear read -p "Please enter your name:" i if [ "$i" = "Tyler" asked 11 months ago viewed 305 times active 11 months ago Related 1“syntax error: unexpected end of file” simple script0How do I solve this “unexpected '}' syntax error” in my bash Integer Expression Expected Questions about other Linux distributions can be asked on Unix & Linux, those about Windows on Super User, those about Apple products on Ask Different and generic programming questions on Stack

It's pretty hard to understand the code like this. Thank you for this introduction to it's use and proper indentation. forgot about the PS3 feature in select 2. http://mmonoplayer.com/syntax-error/syntax-error-near-unexpected-token-then-39-in-shell-script.html I am trying to put together a script (see below) that will backup data to a removable HHD by date.

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 Aligning texts side by side with equations in \align environment French vs Italian resistance Is there a performance difference in the 2 temp table initializations? Why is the Vitamin B complex, a "complex"? Anxious about riding in traffic after 20 year absence from cycling Can a free radical be created by chemical reaction of non-radical species?

Fixed. And to you and yours, I wish the very best for the coming new year. share|improve this answer edited Jun 3 '12 at 14:51 answered Jun 3 '12 at 13:33 Gilles 33.6k683126 [[ $3 < 50 ]] compares $3 with 50 lexicographically, so if all of you are right.

Will a tourist have any trouble getting money from an ATM India because of demonetization? The time now is 10:20 PM. Does enlarging a character with a reach weapon affect his threat range? Shotts, Jr.

Last edited by T3RM1NVT0R; 12-30-2011 at 01:12 PM. By doing this, you can isolate which part of a program is causing (or not causing) a problem. it kicks back with " line 42: syntax error: unexpected end of file " after entering the data into the first user input prompt for the name. #!/bin/bash clear read -p 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

Thanks for the heads up brother. Empty variables Edit the script to change line 3 from: number=1 to: number= and run the script again.