Solved

help with a shell script for ubuntu

Posted on 2011-02-23
19
387 Views
Last Modified: 2012-05-11
Hi,

I am trying to use named-checkzone on a list of zones I have called zonelist

The zonelist looks like so:

93.163.128.in-addr.arpa
94.163.128.in-addr.arpa
95.163.128.in-addr.arpa
96.163.128.in-addr.arpa
97.163.128.in-addr.arpa
98.163.128.in-addr.arpa
99.163.128.in-addr.arpa
a2zce.com
a2zce.org
accn.foo.edu
adrc.foo.edu
aen.foo.edu

What I have is: ( see below code )

When I run it, I get the below error:

./check-zone-script.sh

./check-zone-script.sh: line 2: unexpected EOF while looking for matching `''
./check-zone-script.sh: line 12: syntax error: unexpected end of file

Do you guys have a better way to code this?
#
for zone in 'cat zonelist`
do
zonefile=db.$zone
echo "***** CheckZone on $zone zone. *****" >> checkzone.log
/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zonefile >>
checkzone.log
#
echo "**********************************************************" >>
checkzone.log
done

Open in new window

0
Comment
Question by:richsark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 8
19 Comments
 
LVL 16

Expert Comment

by:sjklein42
ID: 34965104
Your "for zone" line ends with a backtick (`) rather than a single quote (')
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34965165
Or maybe it's the other way around.  You probably want them both to be backticks.  Either way, they need to match.  :)
0
 
LVL 1

Author Comment

by:richsark
ID: 34965832
Hi,

I did that :)

#
for zone in `cat zonelist`
do
zonefile=zonelist$zone
echo "***** CheckZone on $zone zone. *****" >> checkzone.log
/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zonefile >>
checkzone.log
#
echo "**********************************************************" >>
checkzone.log
done


When I run it I still get an error

./check-zone-script.sh: line 6: syntax error near unexpected token `newline'
./check-zone-script.sh: line 6: `/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zonefile >>'

would you have a more better way to make this work??
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 16

Expert Comment

by:sjklein42
ID: 34965933
Is checkzone.log really on a separate line?  It needs to be on the same line as the >>
#
for zone in `cat zonelist`
do
zonefile=zonelist$zone
echo "***** CheckZone on $zone zone. *****" >>checkzone.log
/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zonefile >>checkzone.log
#
echo "**********************************************************" >>checkzone.log
done

Open in new window

0
 
LVL 1

Author Comment

by:richsark
ID: 34966266
Hi,
Much better, But somehow its appending a word zonelist10.163.128.....
I dont need it that word 'zonelist', that is why its failing.

zone 10.163.128.in-addr.arpa/IN: loading from master file zonelist10.163.128.in-addr.arpa failed: file not found
zone 10.163.128.in-addr.arpa/IN: not loaded due to errors.
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34966342
You are doing that to yourself on line 4 ( zonefile=zonelist$zone ).

What is supposed to be the difference between the $zone and $zonefile, and what is the following command supposed to look like when it is really executed:

/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zonefile >>checkzone.log
0
 
LVL 1

Author Comment

by:richsark
ID: 34966357
Hi,

The command line is

named-checkzone kyddnetwork.org kyddnetwork.org.db
0
 
LVL 1

Author Comment

by:richsark
ID: 34966385
So, I take whats in the zonelist above which is the actual zone name kyddnetwork.org but the contents are in kyddnetwork.org.db

so zonename then zone.db
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34966392
So in your example

$zone is equal kyddnetwork.org, and

$zonefile is supposed to be kyddnetwork.org.db ?

Is the only difference that there is always ".db" appended to the end of the $zone?  Or how else do you get $zonefile from $zone?

If just appending .db, then try this:

#
for zone in `cat zonelist`
do
echo "***** CheckZone on $zone zone. *****" >>checkzone.log
/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zone.db >>checkzone.log
#
echo "**********************************************************" >>checkzone.log
done

Open in new window

0
 
LVL 1

Author Comment

by:richsark
ID: 34966437
HI,
Its still appending "zonelist"

***** CheckZone on 101.163.128.in-addr.arpa zone. *****
zone 101.163.128.in-addr.arpa/IN: loading from master file zonelist101.163.128.in-addr.arpa failed: file not found
zone 101.163.128.in-addr.arpa/IN: not loaded due to errors.

Yes, the only difference is it appends the word db after the zonename
0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34966481
There must be a glitch somewhere.  Try this - it will echo into the log file the named-checkzone command we are about to execute.  I don't see where it could be adding the "zonelist" anymore, but this may show something.

#
for zone in `cat zonelist`
do
echo "***** CheckZone on $zone zone. *****" >>checkzone.log
echo "/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zone.db" >>checkzone.log
/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zone.db >>checkzone.log
#
echo "**********************************************************" >>checkzone.log
done

Open in new window

0
 
LVL 1

Author Comment

by:richsark
ID: 34966499
Humm, some how it aint putting the .db in


***** CheckZone on 98.163.128.in-addr.arpa zone. *****
zone 98.163.128.in-addr.arpa/IN: loading from master file zonelist98.163.128.in-addr.arpa failed: file not found
zone 98.163.128.in-addr.arpa/IN: not loaded due to errors.
**********************************************************
***** CheckZone on 99.163.128.in-addr.arpa zone. *****
zone 99.163.128.in-addr.arpa/IN: loading from master file zonelist99.163.128.in-addr.arpa failed: file not found
zone 99.163.128.in-addr.arpa/IN: not loaded due to errors.
**********************************************************
***** CheckZone on a2zce.com zone. *****
zone a2zce.com/IN: loading from master file zonelista2zce.com failed: file not found
zone a2zce.com/IN: not loaded due to errors.
**********************************************************
***** CheckZone on a2zce.org zone. *****
zone a2zce.org/IN: loading from master file zonelista2zce.org failed: file not found
0
 
LVL 1

Author Comment

by:richsark
ID: 34966545
Does this help?

root@ubuntu:/home/richsark/uky-dns/ncc.021811# named-checkzone

usage: named-checkzone [-djqvD] [-c class] [-f inputformat] [-F outputformat] [-t directory] [-w directory] [-k (ignore|warn|fail)] [-n (ignore|warn|fail)] [-m (ignore|warn|fail)] [-r (ignore|warn|fail)] [-i (full|full-sibling|local|local-sibling|none)] [-M (ignore|warn|fail)] [-S (ignore|warn|fail)] [-W (ignore|warn)] [-o filename] zonename filename
0
 
LVL 1

Author Comment

by:richsark
ID: 34966594
perhaps we scratch what I did and make something else that works.

all my *.db files are in the same working directory as the file name zonelist

/home/richsark/uky-dns/ncc.021811
0
 
LVL 1

Author Comment

by:richsark
ID: 34966634
ok.,

Weird, I was doing this in Ubtunu,

Then I went to my windows7 box using cygwin and it works using this:


#
for zone in `cat zonelist`
do
echo "***** CheckZone on $zone zone. *****" >>checkzone.log
#echo "/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zone.db" >>checkzone.log
named-checkzone -w . $zone $zone.db >>checkzone.log
#
echo "**********************************************************" >>checkzone.log
done

Open in new window

0
 
LVL 16

Expert Comment

by:sjklein42
ID: 34966661
I hate to say it but it seems like you weren't editing the right file when you were trying it on Ubuntu.
0
 
LVL 1

Author Comment

by:richsark
ID: 34966697
Well, in windows it aint working fine either

zone uky.edu/IN: getaddrinfo(alt2.aspmx.l.google.com) failed: Either the application has not called WSAStartup, or WSAStartup failed.

I am using the same file.... will remove a re-due

Do you have a better way please??
0
 
LVL 1

Author Comment

by:richsark
ID: 34966736
LOL,

seems to me that the checkzone.log was being appended ! rather then a new one. Can we adjust for that?

so I removed the log and works, I was going nuts !!

Below is what ended up working.


#
for zone in `cat zonelist`
do
echo "***** CheckZone on $zone zone. *****" >>checkzone.log
#echo "/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zone.db" >>checkzone.log
named-checkzone $zone $zone.db >>checkzone.log
#
echo "**********************************************************" >>checkzone.log
done

Open in new window

0
 
LVL 16

Accepted Solution

by:
sjklein42 earned 500 total points
ID: 34966761
I hate it when that happens!  I do it to myself, too.  And I even thought about that and decided you must be clearing the file elsewhere!  LOL indeed.

Add a line to reset the log file at the start of the procedure:

#
echo >checkzone.log
for zone in `cat zonelist`
do
echo "***** CheckZone on $zone zone. *****" >>checkzone.log
#echo "/usr/sbin/named-checkzone -t /home/richsark/uky-dns/ncc.021811 $zone $zone.db" >>checkzone.log
named-checkzone $zone $zone.db >>checkzone.log
#
echo "**********************************************************" >>checkzone.log
done
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question