Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


Search this Thread
Old 06-08-2011, 12:53 PM   #1
LQ Newbie
Registered: Aug 2003
Posts: 15

Rep: Reputation: 0
Problem with Bash Script

Hi All,

I'm trying to create a bash script to do the following:

* Mount an NFS dir to local MNT
* Copy cups ppd file from MNT to /etc/cups/ppd
* Substitute entries for old printer to new in /etc/cups/printers.conf
* Restart cups

Here is the code:

#!/bin/sh -x


# Create MP for /unix/export
# and copy ppd file to local
# ppd dir in /etc/cups

if [ ! -d $MNT ]; then
echo "Create MNT!"
mkdir -p $MNT
echo "Dir Exists!
mount $EXPORT $MNT
cp -p $MNT/$FILE $PPD

# Backup up printers.conf file
# and edit with sed

if [ -f $PRINT_CONF ]; then
# unalias cp
sed -e "s/ps6/ps9/g;s/P4010/P4015x/g" \

# Restart the cups daemon
/etc/init.d/cups restart

When I run the code I get the following:

# ./
./ line 30: unexpected EOF while looking for matching `"'
./ line 36: syntax error: unexpected end of file

Any help would be appreciated

Old 06-08-2011, 12:59 PM   #2
Senior Member
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux
Posts: 2,819
Blog Entries: 1

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
sed -e "s/ps6/ps9/g;s/P4010/P4015x/g" \
can be changed to:

sed -i 's/ps6/ps9/g' $PRINT_CONF
sed -i 's/P4010/P4015x/g' $PRINT_CONF

Last edited by szboardstretcher; 06-08-2011 at 01:01 PM.
Old 06-08-2011, 01:22 PM   #3
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946Reputation: 1946
The error message is telling you the problem.

unexpected EOF while looking for matching `"'
It's telling you it reached the end of the file without finding a closing quotation mark. In this case, in this line:
echo "Dir Exists!
The frustrating thing about this kind of error is that the line numbers it gives you will often not match the actual location of the problem. Mismatched opening and closing quotes can propagate through the entire code until it reaches the last unmatched individual near end of the file.

PS: Please use [code][/code] tags around your code, to preserve formatting and to improve readability.
Old 06-08-2011, 02:24 PM   #4
LQ Newbie
Registered: Aug 2003
Posts: 15

Original Poster
Rep: Reputation: 0

Guys, thanks for your responses...the problem turned out to be the missing " as David the H had mentioned. I apologize for the missing tags, but I didn't see there mention when I was creating the post, so I wasn't sure if they were required.

Thanks Again!
Old 06-08-2011, 08:02 PM   #5
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,425

Rep: Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876Reputation: 1876
Please mark as SOLVED if you have a working solution.


bash, shell script

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
Problem running an Expect script within a Bash script mbeipi Programming 8 03-15-2011 04:07 PM
SSH connection from BASH script stops further BASH script commands tardis1 Linux - Newbie 3 12-06-2010 08:56 AM
Bash script problem with ftp session exiting the script early edomingox Programming 5 02-23-2010 05:39 AM
[SOLVED] bash : getopts problem in bash script. angel115 Programming 2 03-02-2009 10:53 AM
Problem with bash script. cheater1034 Programming 9 11-21-2005 10:29 PM

All times are GMT -5. The time now is 01:18 PM.

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