Solved

help with a shell script for ubuntu

Posted on 2011-02-23
19
379 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
  • 11
  • 8
19 Comments
 
LVL 16

Expert Comment

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

Expert Comment

by:sjklein42
Comment Utility
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
Comment Utility
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
 
LVL 16

Expert Comment

by:sjklein42
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hi,

The command line is

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

Author Comment

by:richsark
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 1

Author Comment

by:richsark
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Utilizing an array to gracefully append to a list of EmailAddresses
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now