LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
LinkBack Search this Thread
Old 06-08-2011, 12:53 PM   #1
maker10
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

EXPORT=unix_vs:/unix/export
MNT=/mnt/printer
FILE=/is/ppd/ps9.ppd
PRINT_CONF=/etc/cups/printers.conf
PPD=/etc/cups/ppd
CUPS=/etc/cups

# 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
else
echo "Dir Exists!
fi
mount $EXPORT $MNT
cp -p $MNT/$FILE $PPD

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

if [ -f $PRINT_CONF ]; then
cp -p $PRINT_CONF $PRINT_CONF.orig
fi
# unalias cp
sed -e "s/ps6/ps9/g;s/P4010/P4015x/g" \
$PRINT_CONF > $PRINT_CONF.tmp
cp -u $PRINT_CONF.tmp $PRINT_CONF

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

When I run the code I get the following:

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

Any help would be appreciated

Thx...
 
Old 06-08-2011, 12:59 PM   #2
szboardstretcher
Senior Member
 
Registered: Aug 2006
Distribution: Arch 2014.02.01
Posts: 2,317
Blog Entries: 1

Rep: Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741Reputation: 741
Code:
sed -e "s/ps6/ps9/g;s/P4010/P4015x/g" \
$PRINT_CONF > $PRINT_CONF.tmp
cp -u $PRINT_CONF.tmp $PRINT_CONF
can be changed to:

Code:
cp -u $PRINT_CONF $PRINT_CONF.old
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.

Code:
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:
Code:
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
maker10
LQ Newbie
 
Registered: Aug 2003
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks!

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
grail
Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 7,192

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


Reply

Tags
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
Trackbacks are Off
Pingbacks are On
Refbacks are 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 02:40 AM.

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