#94956 - 2002-10-29 05:47 PM
Re: Challenge for Shawn...
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
this does something like that...
you will need a whole series of UDFs to make this work.
code:
break on call \\a06\logon\udf.kix
dim $namearray[2,1] $ip1 ="100.151.234.1" $sn1 ="255.255.255.128" $iparray=IPRange($ip1,$sn1)
$index=0 for each $ip in $iparray ? "$ip " if $ip $hostname=lookup($ip) if not @error "$hostname $index" $namearray[0,$index]=$hostname $namearray[1,$index]=$ip $index=$index+1 redim preserve $namearray[2,$index] else $p=WSHPing($ip) if $p[1]=1 "IP Active" else "No Reply" endif endif endif next
redim preserve $namearray[2,$index-1] :l for $loop=0 to ubound($namearray,2) $computer =$namearray[0,$loop] $ipaddr =$namearray[1,$loop] $ping ="" $remoteuser="" if $computer $p=WSHPing($ipaddr) $ip=$p[0] $ping=$p[1] endif if $ping=1 $remoteuser=wmiquery("UserName","Win32_ComputerSystem",$computer) $color="color b+/n" if exist("\\$computer\C$\Program Files\hotbar") $=sendmessage(@wksta,"Hotbar on $computer") endif endif if $remoteuser="" select case $ip= "0.0.0.0" $remoteuser="unknown" $color="color w/n" case $ping=-1 $remoteuser="Down" $color="color r+/n" case 1 $remoteuser="On-line" $color="color g+/n" endselect endif if len($computer)<8 $computer="$computer " endif if $ip= "0.0.0.0" $ip= "0.0.0.0 " endif $_=execute("? '$$computer $$ip '$color $$remoteuser color w/n") next ? sleep 30 goto l exit
Function IPRange($sIPaddress,$sNetMask) Dim $aiStartRange,$aiMaskBits,$aiEndRange[4],$iHostCount,$i Dim $iOctet1,$iOctet2,$iOctet3,$iOctet4 Dim $tempArray[1]
$iHostCount=1
$aiStartRange=Split($sIPaddress,".") $aiMaskBits=Split($sNetMask,".") Redim Preserve $aiStartRange[4] Redim Preserve $aiMaskBits[4]
For $i = 0 To 3 $aiMaskBits[$i] =Val($aiMaskBits[$i]) & 255 $aiStartRange[$i] =Val($aiStartRange[$i]) & $aiMaskBits[$i] $aiEndRange[$i] =$aiStartRange[$i]+(255-$aiMaskBits[$i]) $iHostCount =$iHostCount*($aiEndRange[$i]-$aiStartRange[$i]+1) Next
redim $temparray[$iHostCount] $i=0 For $iOctet1 = $aiStartRange[0] To $aiEndRange[0] For $iOctet2 = $aiStartRange[1] To $aiEndRange[1] For $iOctet3 = $aiStartRange[2] To $aiEndRange[2] For $iOctet4 = $aiStartRange[3] To $aiEndRange[3] $temparray[$i]="$iOctet1.$iOctet2.$iOctet3.$iOctet4" $i=$i+1 Next Next Next Next $IPRange=$temparray EndFunction
|
|
Top
|
|
|
|
#94958 - 2002-10-29 06:06 PM
Re: Challenge for Shawn...
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
ubound is built in also wshpipe()
Don't forget to supply a class C network (IP & subnet) to scan
BTW, remove: if exist("\\$computer\C$\Program Files\hotbar") $=sendmessage(@wksta,"Hotbar on $computer") endif
as I hijaacked this script to do something else, and hadn't removed it [ 29. October 2002, 18:07: Message edited by: Radimus ]
|
|
Top
|
|
|
|
#94960 - 2002-10-29 07:10 PM
Re: Challenge for Shawn...
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
|
|
Top
|
|
|
|
#94962 - 2002-10-29 07:25 PM
Re: Challenge for Shawn...
|
Radimus
Moderator
   
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
does 4.10 support 2d arrays?
I'm running 4.12b1 (needed to have COM fixed)
|
|
Top
|
|
|
|
Moderator: Arend_, Allen, Jochen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Mart
|
0 registered
and 735 anonymous users online.
|
|
|