#120915 - 2004-06-09 05:47 PM
Script to execute program on 20 subnets
|
Jharper
Fresh Scripter
Registered: 2003-07-29
Posts: 13
|
Hey guys, My dilemma is that I need to write a script that runs through all of the IPs in the DHCP scope (24 bit mask / 50-254) in 20 different subnets and pass the IP to a program as a parameter. I can't decide the best way to do this. I know the very basics of KiX scripting but need a something basic to get me started. Any help would be much appreciated.
Thanks, Jharper
|
|
Top
|
|
|
|
#120917 - 2004-06-09 05:55 PM
Re: Script to execute program on 20 subnets
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
|
|
Top
|
|
|
|
#120918 - 2004-06-09 05:57 PM
Re: Script to execute program on 20 subnets
|
Jharper
Fresh Scripter
Registered: 2003-07-29
Posts: 13
|
LOL! Nothing that exciting, My company has 20 offices spread out across the U.S. I'm looking to create some tasks that run periodically that do auditing and some other things at the same time.
|
|
Top
|
|
|
|
#120919 - 2004-06-09 07:27 PM
Re: Script to execute program on 20 subnets
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
look for MOAN() in the UDF forum...
you can pass it a networkID and SNM and it will return an array of IPs
|
|
Top
|
|
|
|
#120921 - 2004-06-09 07:37 PM
Re: Script to execute program on 20 subnets
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
there is also EnumDHCP() udf that will get the IPs from the server
|
|
Top
|
|
|
|
#120923 - 2004-06-09 07:55 PM
Re: Script to execute program on 20 subnets
|
Jharper
Fresh Scripter
Registered: 2003-07-29
Posts: 13
|
Thanks Les, that's what I needed. I appreciate everyone's input. I knew the KiX masters could help me out!
Thanks again, Jharper
|
|
Top
|
|
|
|
#120924 - 2004-06-09 08:02 PM
Re: Script to execute program on 20 subnets
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
time to nitpick... oct 4 in a class c can't be 0 or 255, so the for/next should be modified
and 1 or 254 is usually the router...
Edited by Radimus (2004-06-09 08:04 PM)
|
|
Top
|
|
|
|
#120925 - 2004-06-09 08:04 PM
Re: Script to execute program on 20 subnets
|
Jharper
Fresh Scripter
Registered: 2003-07-29
Posts: 13
|
I've already changed it to 50 - 254. This is the served scope set for all subnets in my network.
Edited by Jharper (2004-06-09 08:06 PM)
|
|
Top
|
|
|
|
#120927 - 2004-06-10 05:41 PM
Re: Script to execute program on 20 subnets
|
Bryce
KiX Supporter
   
Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
|
just because i did the work... might as well post it 
Needs BinaryIP() and BaseConverter()
Code:
Function GetSubnetIPs($subnet,$subnetmask) dim $1,$0,$subnetid,$i,$convert $1 = "11111111111111111111111111111111" $0 = "00000000000000000000000000000000" $subnetmask = substr(binaryip($subnetmask),1,instr(binaryip($subnetmask),0)-1) $subnetid = substr(binaryip($subnet),1,len($subnetmask)) $subnet = substr(binaryip($subnet),len($subnetmask)+1) dim $tarray[baseconverter(substr($1,1,len($subnet)),2,10)] for $i = 0 to ubound($tarray) $convert = baseconverter($i,10,2) $ip = binaryip($subnetid + substr($0,1,len($subnet)-len($convert)) + $convert,1) $tarray[$i] = $ip next $getsubnetips = $tarray endfunction
EXAMPLE: Code:
$ip = Getsubnetips("128.2.1.0","255.255.192.0") ? $ip[0] ? $ip[ubound($ip)]
Bryce
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Henriques)
and 2516 anonymous users online.
|
|
|