I need help getting this bourne shell script working properly. This script I found online while reading some tutorials on getting a caching name server running, which is supposed to update the rootserver hints file. The original script is found here: http://tldp.org/HOWTO/DNS-HOWTO-8.html
When I run the command:
[cmd=]dig @e.root-servers.net . ns > root.hints.new 2> errors[/cmd]
outside of the script I get an ambiguous command error.
When I use the command
[cmd=]dig @e.root-servers.net . ns > root.hints.new[/cmd]
I have no troubles. What's the problem here? Is it because it is writing the results to 2 files?
Also the below case statement always returns that the hints file has failed. Even though when I check the file it looks normal and I can see the NOERROR status in the returned header.
I have also been wanting to turn these case statements into if statements if anyone could help me with the syntax for that. I don't typically like to use case statements when there is usually only 1 or 2 possible results. The problem I'm having here is that I can't seem to put command output into a string/variable. See the code below for an example of my intentions.
Maybe it's just me but I think the if statement looks cleaner than the case statement used in the original script.
Extra information:
I'm running this on FreeBSD 8.2-RELEASE.
The caching name server is working with no problems.
When I run the command:
[cmd=]dig @e.root-servers.net . ns > root.hints.new 2> errors[/cmd]
outside of the script I get an ambiguous command error.
When I use the command
[cmd=]dig @e.root-servers.net . ns > root.hints.new[/cmd]
I have no troubles. What's the problem here? Is it because it is writing the results to 2 files?
Also the below case statement always returns that the hints file has failed. Even though when I check the file it looks normal and I can see the NOERROR status in the returned header.
Code:
dig @e.root-servers.net . ns >root.hints.new 2> errors
case `cat root.hints.new` in
*NOERROR*)
# It worked
:;;
*)
echo "Subject: The root.hints file update has FAILED."
echo
echo "The root.hints update has failed"
echo "This is the dig output reported:"
echo
cat root.hints.new errors
exit 1
;;
esac
I have also been wanting to turn these case statements into if statements if anyone could help me with the syntax for that. I don't typically like to use case statements when there is usually only 1 or 2 possible results. The problem I'm having here is that I can't seem to put command output into a string/variable. See the code below for an example of my intentions.
Code:
#Code to check if named is running.
status = 'rndc status | grep server'
if [ $status != 'server is up and running' ]
echo "Named is not running!"
echo "Exiting."
exit 0
fi
Maybe it's just me but I think the if statement looks cleaner than the case statement used in the original script.
Extra information:
I'm running this on FreeBSD 8.2-RELEASE.
The caching name server is working with no problems.