Linux / UNIX Tech Support Forum
This is a discussion on Shell BIND NAMED Zone Creation Script within the Shell scripting forums, part of the Development/Scripting category; Hi Code: ######################################### #!/bin/bash -x NAMED_CONF_PATH="/etc/named.conf" gen="generic.hosts" domainame="" echo -n "Enter Domain Name : " read domainame if grep \"$domainame\" ...
|
|||||||
| Shell scripting You can discuss the shell scripting, request shell scripts and scripting techniques |
![]() |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
Hi
Code:
#########################################
#!/bin/bash -x
NAMED_CONF_PATH="/etc/named.conf"
gen="generic.hosts"
domainame=""
echo -n "Enter Domain Name : "
read domainame
if grep \"$domainame\" $NAMED_CONF_PATH > /dev/null ;
then
echo "Domain $domainame already exists, please try another domain"
exit 1
fi
echo "zone \"$domainame\" {" >> $NAMED_CONF_PATH
echo " type master; " >> $NAMED_CONF_PATH
echo " file \"$gen\";" >> $NAMED_CONF_PATH
echo "};" >> $NAMED_CONF_PATH
echo "" >> $NAMED_CONF_PATH
###################################################
I want it to be as if no domain name or no value is entered it should be exit else further performe, Can anyone help me into it??????? Thanks...... Last edited by nixcraft; 12-02-2009 at 11:11 PM. |
| Sponsored Links | ||
|
|
|
||||
|
Replace
Code:
read domainame Code:
read domainame [ "$domainame" != "" ] || ( echo "Usage: $0 domainname"; exit 1)
__________________
Vivek Gite Linux Evangelist |
|
|||
|
Thanks Dear,
But i've done this with the following... It works. what i wanted. ###################################### #!/bin/bash namepath="/etc/named.conf" domainame="" gen="generic.hosts" clear echo "e.g. 'example.com'" echo -n "Enter Domain Name : " read domainame if [ "$domainame" = "" ] then clear echo "You 've not entered any Domain Name, try again" exit 1 else if grep \"$domainame\" "$namepath" > /dev/null ; then clear echo "Domain $domainame already exists, please try another domain" exit 1 fi fi echo "zone \"$domainame\" {" >> $namepath echo " type master; " >> $namepath echo " file \"$gen\";" >> $namepath echo "};" >> $namepath echo "" >> $namepath clear echo "Zone Record for the Domain '$domainame' is Successfully created" ################################################## #### |
|
||||
|
Yes, it works both ways but my code is short.
Short code == faster execution Heh
__________________
Vivek Gite Linux Evangelist |
![]() |
| Tags |
| bind , bind shell script , named , named shell script , zone creation shell script |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to Delete a file on 46 th day from the day of creation | knvpavan | Shell scripting | 6 | 12-02-2009 12:07 AM |
| getting errors from named.conf in rhel5 | ashu.wifi | CentOS / RHEL / Fedora | 2 | 17-09-2008 02:02 PM |
| Binary Conversion Of Shell Script (shell script compiler) | chandanperl | Shell scripting | 3 | 29-07-2008 10:22 AM |
| Linux Change the time zone configuration after installation | raj | Linux software | 1 | 17-07-2006 02:11 AM |
| mysql account creation | Linux software | 1 | 28-01-2006 11:17 AM | |