Unexpected end of file error in unix shell script




















Try this:! Mona Jalal Mona Jalal Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually.

Related Hot Network Questions. Question feed. Show Threads. Show Posts. Shell Programming and Scripting.

Top Forums Shell Programming and Scripting syntax error: unexpected end of file. Registered User. Join Date: Dec Join Date: Feb You haven't close the limit string of the here document: Code :. Hi, May you tell me where exactly to put it, cause i tried it in many palces, and still the same :S!!

Originally Posted by Alaeddin. Join Date: Nov Hope you understand now. Code :. This error occurs often when you have mismatched structure - that is, you do not have matching double quotes, matching single quotes, have not closed a control structure such as a missing fi with an if , or a missing done with a for.

The best way to spot these is to use correct indentation, which will show you where you have a broken control structure, and syntax highlighting, which will show you where quotes are not matched. In this particular case, I can see you are missing a fi. In the latter part of your code, you have 5 if s and 4 fi s. In my case, I found that placing a here document like sqplus Unrelated to the OP's problem, but my issue was that I'm a noob shell scripter.

All the other languages I've used require parentheses to invoke methods, whereas shell doesn't seem to like that. I have found that this is sometimes caused by running a MS Dos version of a file. If that's the case dos2ux should fix that. Remove indentation as shown below. Posting this because it took me over an hour to figure out the error. I had this problem when running some script in cygwin. Fixed by running dos2unix on the script, with proper description of problem and solution given in that answer.

I agree with camh, that correct indentation from the beginning helps to avoid such errors. Finding the desired way later means double work in such spaghetti code. If you can't see it just by looking I'd recommend a syntax colouring editor and a neat indentation style , take a copy of the script, and delete half of it, cutting it of somewhere that ought to be valid. If the script runs, as far as it can, then the problem is in the other half. Repeat until you've narrowed down the problem.

You can delete the semicolons at the ends of lines , , , , and Again, this is basically an issue of style. For example, if deleting lines does make the error go away, put them back in, but then delete lines , , and In other words, use the process of elimination.

Add a comment. Active Oldest Votes. Improve this answer. Janis Janis Thanks for the reply. I have found the error and fixed it!



0コメント

  • 1000 / 1000