Writing to a specific line in a text file (.cfg)
I manage several Netgear WAP's at several remote locations. I use MAC filtering, which can be difficault to add device MACs to several sites. I usually make a backup.cfg file then add the lines, under the access control table, needed to add a MAC and name to the table. Then restore the backup. I would like to have a script the would prompt a local user for the Device Name and MAC address then search the .cfg file for the Access Control Table and add the line with the new MAC and Name. I have looked over the filesystem object and the text stream method and have not found away to search the .cfg file for a specific section or line then add a line to that section. I guess the hardest part is finding the section then pointing to the correct location the write the line.
SAMPLE NETGEAR.CFG
[528000:Static Routes]
[528001:Static Routing Table]: {
}
[530000:Wireless Configuration]
[530001:SSID]: hammon
[530002:Channel]: 10
[530003:Access Control]: on
[530004:Bridge Enable]: on
[530016:Security Type]: WEP
#usage: None|WEP|WPA_PSK|WPA_8021X
[530005:Access Control Table]: {
[530005_e]: 1) "00-90-96-G6-0d-32" "Laptop 5-57"
[530005_e]: 2) "00-90-96-H6-0d-1e" "Laptop 1-53"
[530005_e]: 3) "00-90-96-J6-99-76" "Laptop 4-56"
[530005_e]: 4) "00-0c-f1-J6-f8-5c" "Laptop 2-54"
[530005_e]: 5) "00-0c-f1-K6-df-63" "Laptop 7-59"
[530005_e]: 6) "00-0c-f1-L7-5e-32" "Laptop 9-61"
[530005_e]: 7) "00-0c-f1-D3-53-4c" "Laptop 6-58"
[530005_e]: 8) "00-0c-f1-F2-56-17" "laptop 8-60"
}
[530006:Authentication Type]: Shared Key
[530007:SSID Broadcast Enable]: on
[530008:Region]: United States
[530009:WEP Key1]: 1e770e0eY6
[530010:WEP Key2]: 1e770e0eY6
[530011:WEP Key3]: 1e770e0eY6
[530012:WEP Key4]: 1e770e0eY6
[530013:Encryption Strength]: 64bit
[530014
[530015:Key length]: 5
[560000:WPA Configuration]
[560001
[560002:Key Lifetime]: 5
[560003
[560004:Secondary Radius Server]:
[560005:Radius Port]: 1812
[560006:8021X Shared Key]:
[560007:Radius Accounting]: disabled
[560008:Radius Accounting port]: 1813
[560009:Update Report Interval]: 5