LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Problem with Bash Script (http://www.linuxquestions.org/questions/programming-9/problem-with-bash-script-885247/)

maker10 06-08-2011 12:53 PM

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...

szboardstretcher 06-08-2011 12:59 PM

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


David the H. 06-08-2011 01:22 PM

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.

maker10 06-08-2011 02:24 PM

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!

grail 06-08-2011 08:02 PM

Please mark as SOLVED if you have a working solution.


All times are GMT -5. The time now is 06:38 PM.