LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-12-2013, 06:05 AM   #1
JankAle
LQ Newbie
 
Registered: Dec 2013
Posts: 3

Rep: Reputation: Disabled
Unexpected end of file


Ich möchte testen, ob 2 Parameter übergeben werden. Wenn nein, dann soll "Test" ausgegeben werden, ansonsten "Hallo".

Code:
#!/bin/bash
if test $# -ne 2
then
	echo "Test"
	exit 1
fi
echo "Hallo"
Ich erhalte folgenden Fehler:

syntax error: unexpected end of file

Woran liegt das? Ich habe ja if...fi gemacht.
 
Old 12-12-2013, 06:09 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
please write in English!
which version of bash do you have. This script works for me.
What kind of OS do you have? Probably you have used Windows to edit that file?
 
Old 12-12-2013, 06:11 AM   #3
JankAle
LQ Newbie
 
Registered: Dec 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Sorry for my German, absent-mindedly I didn't realize that this was an English forum. :P

Yes, I edited that file under windows, but then uploaded it on the server we use for our college courses. I don't know which bash version there is, and I don't know how to find out.
 
Old 12-12-2013, 06:13 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
so the problem is windows eol chars are included, bash cannot understand that.
You need to convert it to unix format (from dos format).
http://www.linuxcommand.org/man_pages/dos2unix1.html

Last edited by pan64; 12-12-2013 at 06:14 AM.
 
Old 12-12-2013, 06:21 AM   #5
JankAle
LQ Newbie
 
Registered: Dec 2013
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks. However, I can't install dos2unix on the server. Is there another work-around?
 
Old 12-12-2013, 06:32 AM   #6
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,133

Rep: Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273Reputation: 2273
http://stackoverflow.com/questions/8...endings-in-vim
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Unexpected end of file Kubik Linux - Newbie 5 10-07-2012 08:06 PM
unexpected end of file btap Programming 14 09-30-2012 01:19 PM
Running a Crafted bash script yelds 'Unexpected end of file' at the end of the file MCLover1337 Linux - General 5 10-15-2011 09:29 AM
unexpected end of file valerio orfano Linux - Newbie 4 12-29-2010 07:16 AM
Unexpected end of file??? raid517 Linux - Software 2 12-01-2004 05:10 AM


All times are GMT -5. The time now is 02:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration