LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 11-04-2016, 02:08 AM   #1
L_Carver
Member
 
Registered: Sep 2016
Location: Webster MA USA
Posts: 241

Rep: Reputation: Disabled
Unhappy Need another pair of eyes (bash script yet again)


I had this one working fine, then I made a slight change and now it's giving the error "line xx - unexpected end of file." I know that usually means a quote string was left open, but I can't see any that are open.

Here is the script:
Code:
#!/bin/bash

function gettext () {
echo -e "What text will I be using?"
read -e item
#Allowing for, and correcting, the trailing space in interactive mode
if [[ "$item" =~ " " ]]; then
	capfile=${item% *}
else
	capfile=$item
fi

#	if [[ ! -f list.txt ]] ; then
#		echo "No list.txt in this directory. Quitting."
#		exit
#	fi
 echo "Uses exiftool."
 while read line; do
	file0=$line
#	locat=$(exiftool -fast5 -p /home/steve/Pictures/location.fmt "$line" 2>/dev/null)
	locat=$(exiv2 -g SubLocation "$line")
	
	if [ ! -z "$locat" ]; then
		echo -e "$file0 has Location data. Writing to file."
		echo -e "$file0^$locat">>has-locations.txt
	else
		echo -e "$file0 has no Location data. Writing filename to file nolocations.txt"
		echo -e "$file0">>nolocations.txt
	fi
done<capfile
It should be quick work finding the string without a closing quote. Any other advice in this direction would also be appreciated.

Carver
 
Old 11-04-2016, 02:39 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,620

Rep: Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608Reputation: 5608
have you ever tried set -xv ?
http://www.linuxquestions.org/questi...4/#post5611481

the closing } of function gettext () { is missing.

also you can try: http://www.shellcheck.net/

Last edited by pan64; 11-04-2016 at 02:45 AM.
 
1 members found this post helpful.
Old 11-04-2016, 02:47 AM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 5,575
Blog Entries: 16

Rep: Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307Reputation: 3307
Quote:
Originally Posted by pan64 View Post
have you ever tried set -xv ?
http://www.linuxquestions.org/questi...4/#post5611481

the closing } of function gettext () { is missing.
No, it's there but in the wrong place. You can't have a closing brace in the middle of an if..fi structure. Move it to after "fi".
 
1 members found this post helpful.
Old 11-04-2016, 03:35 AM   #4
goumba
Senior Member
 
Registered: Dec 2009
Location: New Jersey, USA
Distribution: Current: Debian and OpenSUSE. Past: Arch, RedHat (pre-RHEL). FreeBSD & OpenBSD novice, Hackintosh
Posts: 1,193
Blog Entries: 7

Rep: Reputation: 336Reputation: 336Reputation: 336Reputation: 336
Quote:
Originally Posted by L_Carver View Post

It should be quick work finding the string without a closing quote. Any other advice in this direction would also be appreciated.

Carver
Work on your whitespace. From your other script question, I see your whitespace is inconsistent at best, and makes these jobs more difficult than necessary. Whitespace - while bash can be a bit picky - is your friend, and will help you see things more clearly.
 
1 members found this post helpful.
Old 11-04-2016, 04:42 AM   #5
L_Carver
Member
 
Registered: Sep 2016
Location: Webster MA USA
Posts: 241

Original Poster
Rep: Reputation: Disabled
Exclamation

Quote:
Originally Posted by hazel View Post
No, it's there but in the wrong place. You can't have a closing brace in the middle of an if..fi structure. Move it to after "fi".
Thanks, hazel. I didn't remember the other possible cause for the error (open brackets or parentheses). One forgets a lot when they're off the Net for a year and have no books on these subjects.

Carver
 
  


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
Need another pair of eyes (BASH script throwing a "s-e-n-u-t" error) SilversleevesX Linux - Newbie 6 11-17-2011 09:52 AM
Unexpected end-of-file error (bash script) - need another pair of eyes. SilversleevesX Linux - Newbie 10 02-05-2010 02:21 PM
Unexpected end-of-file error (bash script) - need another pair of eyes. SilversleevesX Linux - Newbie 7 02-05-2010 02:12 PM
I am just not seeing this error kinda need an extra pair of eyes please (C++) jus71n742 Programming 3 03-01-2009 04:24 PM
i need a second pair of eyes spooge Linux - Networking 1 03-16-2005 06:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:33 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
Open Source Consulting | Domain Registration