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

Syntax Error Unexpected End Of File Shell Script

Contents

How exactly do I mark this as answered? As Gordon suggested, change that to: if nc -z $Host $Port then ... Please see the output below: $ ./a.sh ./a.sh: 3: ./a.sh: Host: not found ./a.sh: 4: ./a.sh: Port: not found Usage: ping [-aAbBdDfhLnOqrRUvV] [-c count] [-i interval] [-I interface] [-m mark] [-M Thanks! –WxPilot Jun 19 '14 at 16:26 2 @WxPilot very wrong. http://fullflash.net/syntax-error/syntax-error-unexpected-in-shell-script.html

Regards, Adrian Jedrzejewski jedzio View Public Profile Find all posts by jedzio

#4 07-31-2014 Don Cragun Administrator Join Date: Jul Error messages actually mean something. Origin of “can” in the sense of ‘jail’ Disproving Euler proposition by brute force in C How can I make two cutting lines close to each other? What would have happened to the world if the sepoy mutiny of 1857 had suceeded? http://stackoverflow.com/questions/9886268/shell-script-syntax-error-unexpected-end-of-file

Syntax Error Unexpected End Of File Shell Script

to the title. I should have asked what editor you were using! But you may also get the following: : bad interpreter: No such file or directory Why? You will sometimes want to set a variable's value to nothing.

  1. Password Home Search Forums Register Forum RulesMan PagesUnix Commands Linux Commands FAQ Members Today's Posts Shell Programming and Scripting BSD, Linux, and UNIX shell scripting Post awk, bash, csh, ksh,
  2. 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
  3. Not the answer you're looking for?
  4. In this particular case, I can see you are missing a fi.
  5. Thanks y'all. –Mr.
  6. catkin View Public Profile View LQ Blog View Review Entries View HCL Entries Find More Posts by catkin View Blog 04-29-2010, 11:20 AM #4 roxie600 LQ Newbie Registered: Apr
  7. foo=$(< inputfile) printf "DEBUG: foo is |%q|\n" "$foo" >&2 # exposes whitespace (such as CRs, see below) and non-printing characters Use shell debug output There are two useful debug outputs for

Registration is quick, simple and absolutely free. Note: It seems that here-documents (tested on versions 1.14.7, 2.05b, 3.1.17 and 4.0) are correctly terminated when there is an EOF before the end-of-here-document tag (see redirection). By doing this, you can isolate which part of a program is causing (or not causing) a problem. Syntax Error At Line (' Unexpected share|improve this answer edited Jun 19 '14 at 16:37 answered Jun 19 '14 at 16:23 Oli♦ 173k56437646 add a comment| up vote 0 down vote If you are using vim or

Thank you for the quickness of your response. Bash Unexpected End Of File While Looking For Matching The debug.sh script is (feel free to copy, use and evolve it as you see fit): #!/bin/bash PS4='+(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]:+${FUNCNAME[0]}(): }' export PS4 usage() { cat <<'EOF' usage: debug For details and our forum data attribution, retention and privacy policy, see here Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle Blogs Recent Entries Best Entries Best http://askubuntu.com/questions/485567/unexpected-end-of-file syntax error: unexpected end of file error Shell Programming and Scripting Tags solved Page 1 of 2 1 2 > Thread Tools Search this Thread

How did a CR end up in my file? Java Syntax Error: End Of File Unexpected (expecting ")") Set "execute" permissions (by running "chmod +rx tmp.sh") 5. 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. It's easy to imagine the ^M is bad in other places too.

Bash Unexpected End Of File While Looking For Matching

These are the common things which just slip. http://linuxcommand.org/wss0100.php Is Certificate validation done completely local? Syntax Error Unexpected End Of File Shell Script This technique is called tracing. Syntax Error Unexpected End Of Input You can use cat -vet scriptname to check (look for "^M$" at the ends of lines, instead of just "$"). –Gordon Davisson Jun 17 '15 at 6:29 On a

Why was Susan treated so unkindly? Check This Out Bash 4.0 added an extra message for this: warning: here-document at line delimited by end-of-file (wanted `') Unexpected end of file while looking for matching ... You should always avoid it unless absolutely necessary. –terdon♦ Jun 19 '14 at 16:30 I'll keep that in mind when I'm dealing with scripts –WxPilot Jun 19 '14 at You are currently viewing LQ as a guest. Shell Script Validator

What Cursed Child elements were foreshadowed by Rowling in previous writings? did you close your if with a fi? The ! Source Let's look at the error message again: ./trouble.bash: [: =: unary operator expected We can see that ./trouble.bash is reporting the error and the error has to do with "[".

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" Delimited By End-of-file (wanted `eof') It is useful to know that program flow is happening the way we expect. It happens in interactive shells, when the C-Shell-styled history expansion ("!searchword") is enabled.

If you need to reset your password, click here.

READ YOUR ERROR MESSAGES! This can cause much confusion and many headaches, since lines containing CRs are not what they appear to be when printed. Could you please upload a text file with the script or take a screenshot to make it easier to review? –Eduardo Cola Dec 26 '15 at 15:42 2 With this Syntax Error: End Of File Unexpected (expecting "then") And remove the spaces in the assignment: Host = ############### Port = #### so that becomes: Host=############### Port=#### because assignments will not work properly if there are spaces.

Use set -x to turn tracing on and set +x to turn tracing off. 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 command is syntactically invalid, and you need a space before the closing bracket of an if test. have a peek here How to create a custom theme in SXA?

External commands may display such an error message though in our example, it was the internal test-command that yielded the error. !": event not found $ echo "Hello world!" bash: !": Find all posts by Corona688 #7 07-31-2014 Don Cragun Administrator Join Date: Jul 2012 Last Activity: 30 October 2016, 6:18 PM EDT Location: San Jose, CA, 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