PDA

View Full Version : Shell script complaining of EOF


crashovaride
June 8th, 2007, 03:13 AM
Can someone please help me?

I'm writing a shell script with 500 lines of code. I have checked all my quotations and such and all seem correct. However, when i attempt to run my script, it complains that

"./installer.sh: line 305: syntax error: unexpected end of file"

if needed i can post the code. Can anyone please help?

Thanks,
Crash.

bashologist
June 8th, 2007, 04:15 AM
Yes, post your code if don't wouldn't mind. Have you tried a syntax highlighter? Common mistakes are to mismatch quotes like ending a double quote with a single, forgetting to end the functions body with a semicolon, forgetting a semicolon, forgetting "do", or "then".

Arndt
June 8th, 2007, 05:25 AM
Can someone please help me?

I'm writing a shell script with 500 lines of code. I have checked all my quotations and such and all seem correct. However, when i attempt to run my script, it complains that

"./installer.sh: line 305: syntax error: unexpected end of file"

if needed i can post the code. Can anyone please help?

Thanks,
Crash.

You can run it with
sh -x installer.sh
and see how far it gets.

crashovaride
June 8th, 2007, 05:55 AM
All thank you so much for helping me (this has been removed) for pointing me in the right direction. I have successfully re-written the shell script and it currently works. Thank you for the help in pointing me into the direction of utilizing subroutines. Thanks once again.

Kindest Regards,
Crash.

Arndt
June 8th, 2007, 07:14 AM
well so far, it reaches the if statement where it checks for the N input which is as follows: (this is the entire code.)



A next step can be to remove chunks from the part that is not executed, until you get something small enough to see where the error is by inspection. (Or find that something you removed contained the error.)

crashovaride
June 8th, 2007, 08:25 AM
Is it only me, or does the code look like it should execute with no problems? Because i have taken those sections out. And, it's still complaining.

Arndt
June 8th, 2007, 08:32 AM
Is it only me, or does the code look like it should execute with no problems? Because i have taken those sections out. And, it's still complaining.

Trim it down as far as you can, and then post it again. Can we run it, or do we need particular input files?

jyba
June 8th, 2007, 09:56 AM
[ Message deleted by jyba ]

Mr. C.
June 8th, 2007, 02:41 PM
You have one too many fi keywords just before:

if [ "$selections" = "n" ] || [ "$selections" = "N" ] # If for some reason we aren't doing boston then continue with the others.


Some comments:

a) Use subroutines - you have a lot of identical code, with minor changes. These differences can be consolidated into a single subroutine with a couple of parameters. Lots of copy/pasted code is hard to debug, read, and verify.

b) Replace your long tests (like above) with :

if [[ $var == [yY] ]] ; then
echo match
fi
c) give exit a return value (eg. exit 0).

MrC

stchman
June 8th, 2007, 02:45 PM
Can someone please help me?

I'm writing a shell script with 500 lines of code. I have checked all my quotations and such and all seem correct. However, when i attempt to run my script, it complains that

"./installer.sh: line 305: syntax error: unexpected end of file"

if needed i can post the code. Can anyone please help?

Thanks,
Crash.

Use Gedit to edit your shell scripts. Gedit has syntax highlighting for shell. You may have a mismatched quotation somewhere.

Also when using nested ifs please use intdentation. Makes it much easier to read. The three fi statement I am going to assume those are from nested if statement.

crashovaride
June 8th, 2007, 10:39 PM
ill try and go the route of re-writing the script. i need to learn how to do sub-routines. not that savvy on writing these scripts yet. you can run the applications, but they do require tarballs named accordingly to the script. However, those i cannot release.

Arndt
June 11th, 2007, 04:34 AM
Use Gedit to edit your shell scripts. Gedit has syntax highlighting for shell. You may have a mismatched quotation somewhere.

Also when using nested ifs please use intdentation. Makes it much easier to read. The three fi statement I am going to assume those are from nested if statement.

He did, but it's the text formatting when reading which left aligns everything. When replying, it shows up properly indented. The best thing is to use "code" quoting when posting (the # thing up in the tool bar).