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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
02-04-2010, 02:05 PM
|
#1
|
Member
Registered: May 2009
Posts: 181
Rep:
|
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
|
|
|
02-04-2010, 02:12 PM
|
#2
|
Member
Registered: Sep 2008
Location: MN
Distribution: Gentoo, Fedora, Suse, Slackware, Debian, CentOS
Posts: 100
Rep:
|
Quote:
Originally Posted by SilversleevesX
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
|
|
|
02-04-2010, 02:12 PM
|
#3
|
Senior Member
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833
Rep: 
|
add:
as your 32nd line of the script.
|
|
|
02-04-2010, 02:12 PM
|
#4
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
You're missing a "fi" as the very last line of the file 
|
|
|
02-04-2010, 02:14 PM
|
#5
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
Hmm, seems we all posted at once  -- based on commonalities between the replies, it looks like a missing "fi" is the problem.
|
|
|
02-04-2010, 02:15 PM
|
#6
|
Senior Member
Registered: Jan 2005
Location: Melbourne, Australia
Distribution: Debian Bookworm (Fluxbox WM)
Posts: 1,391
|
Missing 'fi' at the end.
==EDIT==
redundant :-)
|
|
|
02-04-2010, 02:56 PM
|
#7
|
Senior Member
Registered: Jan 2009
Location: "North Shore" Louisiana USA
Distribution: Mint v21.3 & v22.x with Cinnamon
Posts: 1,797
Rep: 
|
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
|
|
|
02-04-2010, 03:37 PM
|
#8
|
Senior Member
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833
Rep: 
|
Quote:
Originally Posted by GrapefruiTgirl
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 
|
|
|
02-04-2010, 05:16 PM
|
#9
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
Yes, like I would be adding some quotes around the "$variables" inside the test cases.
|
|
|
02-05-2010, 02:07 PM
|
#10
|
Member
Registered: May 2009
Posts: 181
Original Poster
Rep:
|
More progress has been made on this thread.
Admins: as OP I request the thread this message appears in be deleted asap.
BZT
|
|
|
02-05-2010, 02:21 PM
|
#11
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Duplicate closed---see link above
|
|
|
All times are GMT -5. The time now is 10:26 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|