Jump to content
Sign in to follow this  
Manjish

Host Resolver

Recommended Posts

Manjish

Hey Guys, I wrote this script which resolves the host names for IP adresses in a pre-selected range.

I made it for a scenario specific to my use, for IP adresses starting from 200.0.2.xx. But i wanted to genralize it, so that it can be used for any ip addresses.

Also my prog checks only odd IPs, since we use dual NICs. Also if the time for script execution could be reduced, it would be better.

Would anyone help me with these tasks, since I am a bit busy with other stuff.If these issues could also be resolved, it would be gr8 to universally use my script. Thanks in advance.

#include <GUIConstantsEx.au3>
#Include <constants.au3>
#include <inet.au3>
#include <WindowsConstants.au3>
#Include <Array.au3>
#Include <Timers.au3>

Opt('MustDeclareVars', 1)
    
Example()

Func Example()
    Global $from, $btn, $msg,$to,$sIp,$sresult,$from1,$to1,$var,$out,$diff,$var1,$from2,$tmpArray[200][2],$i,$j,$k,$l,$varArray,$gui,$iElapse,$sTimerFunc,$T,$far
    $gui=GUICreate(" My GUI input acceptfile", 150, 150, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45, -1, 0x00000018)
    $from1=GUICtrlCreateInput("", 85, 52, 30, 20)
    GUICtrlCreateLabel("IP Address Range", 40, 10)
    GUICtrlCreateLabel("From: 200.0.2.",10,55)
    GUICtrlSetState(-1, $GUI_DROPACCEPTED)
    GUICtrlCreateLabel("To: 200.0.2.",10, 85)
    $to1=GUICtrlCreateInput("", 70, 85, 30, 20)     
    $btn = GUICtrlCreateButton("OK", 50, 110, 60, 20)
    GUISetState()

    Do
        $msg = GUIGetMsg()
        
        Select
            Case $msg = $btn
                ExitLoop
                
        EndSelect
    Until $msg = $GUI_EVENT_CLOSE
EndFunc  


$from=guictrlread($from1)
$to=GUICtrlRead($to1)

if mod($from,2)=0 Then
    $from=$from-1
if mod($to,2)=0 Then
    $to=$to+1
endif
endif

$diff=($to-$from)/2
$var1=("200.0.2."& $from)

$far = Ping($var1, 200)
If $far Then
TCPStartup()
$out=_TCPIpToName ($var1)
Else
$out=("--")
EndIf

If Not IsDeclared('avArray') Then Dim $avArray[1]
            ReDim $avArray[UBound($avArray) + 1]
            $avArray[UBound($avArray) - 1] = $out  

If Not IsDeclared('avArray1') Then Dim $avArray1[1]
            ReDim $avArray1[UBound($avArray1) + 1]
            $avArray1[UBound($avArray1) - 1] = $var1 

for $i=1 to $diff 
$from=$from+2
$var=("200.0.2."& $from)

$far = Ping($var, 100)
If $far Then
TCPStartup()
$sResult = _TCPIpToName ($var)
$out=$sResult
Else
$out=("--")
EndIf

If Not IsDeclared('avArray') Then Dim $avArray[1]
            ReDim $avArray[UBound($avArray) + 1]
            $avArray[UBound($avArray) - 1] = $out  

If Not IsDeclared('avArray1') Then Dim $avArray1[1]
            ReDim $avArray1[UBound($avArray1) + 1]
            $avArray1[UBound($avArray1) - 1] = $var 

next
jet()
pet()

Func jet()
$j=0
for $i=0 to $diff
    $tmpArray[$i][$j]=$avArray[$i+1]
next
EndFunc

func pet()
$k=1
for $l=0 to $diff
    $tmpArray[$l][$k]=$avArray1[$l+1]
next
EndFunc

_ArrayDisplay($tmpArray,"chal")

[font="Garamond"]Manjish Naik[/font]Engineer, Global Services - QPSHoneywell Automation India LimitedE-mail - Manjish.Naik@honeywell.com

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.