LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
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

Closed Thread
 
Search this Thread
Old 02-04-2010, 02:05 PM   #1
SilversleevesX
Member
 
Registered: May 2009
Posts: 181
Blog Entries: 9

Rep: Reputation: 15
Unexpected end-of-file error (bash script) - need another pair of eyes.


I'm pretty much satisfied that all the i's have been dotted and the t's crossed, so far as if/fi, closed parentheses, in-out quotation marks and the like go. I just need another pair of eyes to be sure. My bash shell keeps insisting on there being a line 32 to this script, while nano, vim and the "cat foo.sh | wc -l" combo all agree with my GUI text editor (with which I wrote 98% of the script -- and yes it's been dos2unix'ed as well)-- there are only 31 lines!

Here's the script:

Code:
#!/bin/bash -x
echo -ne "Fixture Identification Fixer for Exiv2 - FIFE\n"
echo -ne "Please enter the name of the file you want to modify.\n"
read gfile
if [ -e $gfile ]
then
	oldf1=$(exiv2 -PInv $gfile | grep 'FixtureId' | sed 's/^FixtureId[       ]*//')
	echo -e "The word or phrase currently in this file reads: ${oldf1}.\n"
	echo -ne "Do you want to change this Fixture ID to something else?  y/n \n"
	read yesorno
	if [ $yesorno = "n" ] 
	then
		echo -ne "No changes made to file ${gfile}\.\n"
	else
		echo "Are you sure? y/n "
		read confirmm
		if [ $confirmm = "n" ]
		then
			exit 1;
		else
			exiv2 -M"del Iptc.Application2.FixtureId" modify $gfile
			echo -e "The old FixtureID has been removed."
			echo -ne "Please enter the word or phrase to replace '$oldfi .'\n"
			read newstringhx
			exiv2 -M"add Iptc.Application2.FixtureId String $newstringhx" modify $gfile
		sleep 1
			echo -ne "The new phrase, \"$newstringhx\",\n has been written to file \033[37;40m${gfile}.\033[0m\n"
		fi
	fi
else
	echo -e "Sorry, that file is not in this folder."
Hope someone finds something. No sweat off my knee if it was something I couldn't see (rhyme unintended).

BZT
 
Old 02-04-2010, 02:12 PM   #2
allanf
Member
 
Registered: Sep 2008
Location: MN
Distribution: Gentoo, Fedora, Suse, Slackware, Debian, CentOS
Posts: 97
Blog Entries: 1

Rep: Reputation: 19
Quote:
Originally Posted by SilversleevesX View Post
I'm pretty much satisfied that all the i's have been dotted and the t's crossed, so far as if/fi, closed parentheses, in-out quotation marks and the like go. I just need another pair of eyes to be sure. My bash shell keeps insisting on there being a line 32 to this script, while nano, vim and the "cat foo.sh | wc -l" combo all agree with my GUI text editor (with which I wrote 98% of the script -- and yes it's been dos2unix'ed as well)-- there are only 31 lines!

Here's the script:

Code:
#!/bin/bash -x
echo -ne "Fixture Identification Fixer for Exiv2 - FIFE\n"
echo -ne "Please enter the name of the file you want to modify.\n"
read gfile
if [ -e $gfile ]
then
	oldf1=$(exiv2 -PInv $gfile | grep 'FixtureId' | sed 's/^FixtureId[       ]*//')
	echo -e "The word or phrase currently in this file reads: ${oldf1}.\n"
	echo -ne "Do you want to change this Fixture ID to something else?  y/n \n"
	read yesorno
	if [ $yesorno = "n" ] 
	then
		echo -ne "No changes made to file ${gfile}\.\n"
	else
		echo "Are you sure? y/n "
		read confirmm
		if [ $confirmm = "n" ]
		then
			exit 1;
		else
			exiv2 -M"del Iptc.Application2.FixtureId" modify $gfile
			echo -e "The old FixtureID has been removed."
			echo -ne "Please enter the word or phrase to replace '$oldfi .'\n"
			read newstringhx
			exiv2 -M"add Iptc.Application2.FixtureId String $newstringhx" modify $gfile
		sleep 1
			echo -ne "The new phrase, \"$newstringhx\",\n has been written to file \033[37;40m${gfile}.\033[0m\n"
		fi
	fi
else
	echo -e "Sorry, that file is not in this folder."
Hope someone finds something. No sweat off my knee if it was something I couldn't see (rhyme unintended).

BZT
Your if is not closed needs a final:
fi
 
Old 02-04-2010, 02:12 PM   #3
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
add:
Code:
fi
as your 32nd line of the script.
 
Old 02-04-2010, 02:12 PM   #4
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
You're missing a "fi" as the very last line of the file
 
Old 02-04-2010, 02:14 PM   #5
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Hmm, seems we all posted at once -- based on commonalities between the replies, it looks like a missing "fi" is the problem.
 
Old 02-04-2010, 02:15 PM   #6
neonsignal
Senior Member
 
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Wheezy (Fluxbox WM)
Posts: 1,363
Blog Entries: 52

Rep: Reputation: 353Reputation: 353Reputation: 353Reputation: 353
Missing 'fi' at the end.

==EDIT==
redundant :-)
 
Old 02-04-2010, 02:56 PM   #7
SaintDanBert
Senior Member
 
Registered: Jan 2009
Location: Austin, TX
Distribution: Mint-15 with Cinnamon & KDE
Posts: 1,361
Blog Entries: 3

Rep: Reputation: 86
You might get this error when your absolutely final record in the script file ends with
Code:
blah blah blah end-of-file
instead of
Code:
blah blah blah newline
end-of-file
Hmmm, should I have used the od --format=x1c command to show this?

~~~ 0;-Dan
 
Old 02-04-2010, 03:37 PM   #8
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
Quote:
Originally Posted by GrapefruiTgirl View Post
Hmm, seems we all posted at once -- based on commonalities between the replies, it looks like a missing "fi" is the problem.
There could be other problems but first cure the obvious
 
Old 02-04-2010, 05:16 PM   #9
GrapefruiTgirl
Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550Reputation: 550
Yes, like I would be adding some quotes around the "$variables" inside the test cases.
 
Old 02-05-2010, 02:07 PM   #10
SilversleevesX
Member
 
Registered: May 2009
Posts: 181
Blog Entries: 9

Original Poster
Rep: Reputation: 15
More progress has been made on this thread.

Admins: as OP I request the thread this message appears in be deleted asap.

BZT
 
Old 02-05-2010, 02:21 PM   #11
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Duplicate closed---see link above
 
  


Closed Thread


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 error when running a shell script Laughing_Man Linux - Newbie 8 09-14-2009 05:43 PM
bash line 74: syntax error: unexpected end of file help? andycol Linux - General 5 09-14-2009 08:12 AM
Bash script -----------syntax error: unexpected end of file ArthurHuang Programming 2 05-01-2009 10:29 AM
Bash script - syntax error: unexpected end of file Mr Pink Programming 7 12-19-2008 06:31 AM
bash "unexpected end of file" script error Runge_Kutta Linux - General 6 05-23-2007 03:36 PM


All times are GMT -5. The time now is 07:09 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration