richsark
asked on
parse through a conf file
HI,
Below is a script that group0 helped me with.
Some how, the output is giving me too many of these
}
}
}
# DHCP_GROUP: SEC
{
I need to have it like so, hence remove the brackets
# DHCP_GROUP: SEC
I cant seem to figure out how to make this script do it
Thanks
Below is a script that group0 helped me with.
Some how, the output is giving me too many of these
}
}
}
# DHCP_GROUP: SEC
{
I need to have it like so, hence remove the brackets
# DHCP_GROUP: SEC
I cant seem to figure out how to make this script do it
Thanks
It seems to be working for me.
How do you run your script?
How do you run your script?
ASKER
It does, but I need to remove this from the output
}
}
}
# DHCP_GROUP: SEC
{
and leave only the # DHCP_GROUP: SEC in each section
}
}
}
# DHCP_GROUP: SEC
{
and leave only the # DHCP_GROUP: SEC in each section
So you don't need to "balance out" the curly braces, i.e. this
# DHCP_GROUP: SEC
group
{
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: SE-ADM1
subnet 144.90.221.128 netmask 255.255.255.128
{
ddns-updates true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option routers 144.90.221.129;
# DHCP_POOL: SE-VLAN20
pool
{
option routers 144.90.221.129;
range 144.90.221.141 144.90.221.240;
}
}
}
Should become this:
group
{
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: SE-ADM1
subnet 144.90.221.128 netmask 255.255.255.128
{
ddns-updates true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option routers 144.90.221.129;
# DHCP_POOL: SE-VLAN20
pool
{
option routers 144.90.221.129;
range 144.90.221.141 144.90.221.240;
If not, please provide an example.
Thanks.
# DHCP_GROUP: SEC
group
{
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: SE-ADM1
subnet 144.90.221.128 netmask 255.255.255.128
{
ddns-updates true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option routers 144.90.221.129;
# DHCP_POOL: SE-VLAN20
pool
{
option routers 144.90.221.129;
range 144.90.221.141 144.90.221.240;
}
}
}
Should become this:
group
{
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: SE-ADM1
subnet 144.90.221.128 netmask 255.255.255.128
{
ddns-updates true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option routers 144.90.221.129;
# DHCP_POOL: SE-VLAN20
pool
{
option routers 144.90.221.129;
range 144.90.221.141 144.90.221.240;
If not, please provide an example.
Thanks.
ASKER
Yes. Correct.
Can the attached script be modified to do this. I could not figure it out.
Can the attached script be modified to do this. I could not figure it out.
Replace line 10 from
next if (/^\s*failover peer/);
to
next if (/^(\s*failover peer|# DHCP_GROUP|\s*})/);
and hopefully that will do the trick...
Good luck!
next if (/^\s*failover peer/);
to
next if (/^(\s*failover peer|# DHCP_GROUP|\s*})/);
and hopefully that will do the trick...
Good luck!
ASKER
Ok. Let me try in the morning and let you know .
Thanks
Thanks
ASKER
Hi, not good yet.
Below is what it looks like from origianl script
This is what I need it to look like
Below is what it looks like from origianl script
dhcpd.conf
# DHCP_GROUP: GV
{
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
max-lease-time 864000;
option domain-name-servers 144.90.3.119, 144.90.182.19;
option ntp-servers 144.90.3.1;
# DHCP_SUBNET: GV-ADM1
subnet 144.90.212.0 netmask 255.255.255.0
{
ddns-updates true;
ping-check true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 864000;
option routers 144.90.212.1;
# DHCP_POOL: GV-VLAN20
pool
{
range 144.90.212.56 144.90.212.240;
}
}
# DHCP_SUBNET: GV-ACA
subnet 144.90.213.0 netmask 255.255.255.0
{
ddns-updates true;
ping-check true;
option netbios-node-type 8;
default-lease-time 86400;
ddns-domainname "edu-domain.pima.edu";
max-lease-time 864000;
option routers 144.90.213.1;
# DHCP_POOL: GV-VLAN30
pool
{
range 144.90.213.56 144.90.213.240;
}
}
}
# DHCP_GROUP: SEC
{
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: SE-ADM1
subnet 144.90.221.128 netmask 255.255.255.128
{
ddns-updates true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option routers 144.90.221.129;
# DHCP_POOL: SE-VLAN20
pool
{
option routers 144.90.221.129;
range 144.90.221.141 144.90.221.240;
}
}
}
# DHCP_GROUP: PCAE-ES
{
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
max-lease-time 864000;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: ES-ADM1
subnet 144.90.232.0 netmask 255.255.255.0
{
ddns-updates true;
ddns-domainname "pcc-domain.pima.edu";
authoritative ;
option routers 144.90.232.1;
# DHCP_POOL: VLAN20
pool
{
option routers 144.90.232.1;
range 144.90.232.56 144.90.232.240;
}
}
This is what I need it to look like
#dhcpd.conf
# DHCP_GROUP: GV
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
max-lease-time 864000;
option domain-name-servers 144.90.3.119, 144.90.182.19;
option ntp-servers 144.90.3.1;
# DHCP_SUBNET: GV-ADM1
subnet 144.90.212.0 netmask 255.255.255.0
{
ddns-updates true;
ping-check true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 864000;
option routers 144.90.212.1;
# DHCP_POOL: GV-VLAN20
pool
{
range 144.90.212.56 144.90.212.240;
}
}
# DHCP_SUBNET: GV-ACA
subnet 144.90.213.0 netmask 255.255.255.0
{
ddns-updates true;
ping-check true;
option netbios-node-type 8;
default-lease-time 86400;
ddns-domainname "edu-domain.pima.edu";
max-lease-time 864000;
option routers 144.90.213.1;
# DHCP_POOL: GV-VLAN30
pool
{
range 144.90.213.56 144.90.213.240;
}
}
# DHCP_GROUP: SEC
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: SE-ADM1
subnet 144.90.221.128 netmask 255.255.255.128
{
ddns-updates true;
option netbios-node-type 8;
default-lease-time 604800;
ddns-domainname "pcc-domain.pima.edu";
max-lease-time 604800;
option routers 144.90.221.129;
# DHCP_POOL: SE-VLAN20
pool
{
option routers 144.90.221.129;
range 144.90.221.141 144.90.221.240;
}
}
# DHCP_GROUP: PCAE-ES
option bootfile-name "BStrap\\X86pc\\BStrap.0";
ddns-updates true;
ping-check true;
option netbios-node-type 8;
next-server 144.90.6.5;
option tftp-server-name "144.90.6.5";
min-lease-time 86400;
default-lease-time 604800;
max-lease-time 864000;
option domain-name-servers 144.90.3.119, 144.90.182.19;
# DHCP_SUBNET: ES-ADM1
subnet 144.90.232.0 netmask 255.255.255.0
{
ddns-updates true;
ddns-domainname "pcc-domain.pima.edu";
authoritative ;
option routers 144.90.232.1;
# DHCP_POOL: VLAN20
pool
{
option routers 144.90.232.1;
range 144.90.232.56 144.90.232.240;
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
AWESOME !
Glad you like.
Happy Perl'ing!
Happy Perl'ing!
ASKER
The origianl thread is here for reference:
https://www.experts-exchange.com/questions/26839982/re-work-an-ISC-DHCPD-CONF-file.html
Thanks
Open in new window
bc-raw.txt