Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

End of File problem 1

Status
Not open for further replies.

BikerGal

Programmer
Jul 12, 2002
17
0
0
GB
I am working on a unix script but when I run it I get the error:
'end of file' unexpected
There are no blank lines after the last line of text. Can you please tell me how to remove this 'end of file' thank you. The last line simply says 'exit'.

thank you a lot for your time
 
Can you post the script if it's not too large?

It's most probably due to an unmatched quote, speech mark or pair of brackets. Or perhaps you've used a << HERE document and left out the HERE, or not placed it at the beginning of a line. Annihilannic.
 
Hi..

This could be a syntax error.Might be a missing of quotes or missing of brackets.Check your script.


Regards

Joe



 
Thanks to ur help I have managed to limit it down to a problem with the while loop. i.e. if I remove the while loop and just run what is in the loop there is no error. I have looked at several sorces and the way that the while loop is structured in unix script varies. I am not sure which way is correct. This is not the script mentioned above but just a test to see if I could get the while loop to work.
I have seen the following two structures in books but when I run them I get the 'unexpected end of file' error:
i=0
while [$i < 10]
echo &quot;Loop: &quot;
echo $i
i=$i+1
done


i=0
while {$i < 10}
{ echo &quot;Loop: &quot;
echo $i
i=$i+1}

It would probably be more suited to a for loop this situation but the general principal is the same.
thanks a lot!!!!
 
You're missing a do between the line containing while and the first echo. Some people to prefer to put ; do on the end of the same line as the while.

Also, to increment i you'll need to use one of the following:

[tt](( i = $i + 1 ))
let i = $i + 1
i=`expr $i + 1`[/tt]

I think the first two are specific to Korn shell? What shell are you using? Annihilannic.
 
Ah, also you need spaces around the test operators, and you can't use '<' (because it treats it as redirection of input).


Try while [ $i -lt 10 ]. 'lt' is short for 'less than'.
Annihilannic.
 
Annihilannic is rigth.

while|for
do
.....
done

don't forget [ is a test operator.
he need a space after [ and a space before ]
-eq -le -gt are arithmetic operators
= is a string operator
in perl it's exactly inversed! -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Hi BikerGal,

Always nice to see another biker at Tek-Tips :)

Anyway.....

Which shell are you using for your script? Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Bourne Shell. This problem has been fixed now thanx to all your helpful advice but alas there are more issues now! Anyway this is the way to learn..... I have a Kawasaki zxr 400 and a BSA C10 what do u have Mike. If your American I know some of the Japenese bikes have different names there I am Irish.

thanx a lot again!
 
BikerGal,

Just wanted to say a little &quot;Hello&quot; from a french Kawasaki ZX-9R :)
&quot;Men in green&quot; are everywhere !
 
BMW K100RT, and I'm in the UK :) I used to ride a Kawasaki though, so those are cool as well....

More issues you said? Mike

Want to get great answers to your Tek-Tips questions? Have a look at faq219-2884
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top