Jump to content

IP to Net name


Recommended Posts

Is it posible to convert a IP to net name?

do a ping with the -a parameter. This will work on domains. For home networks you could do net view and then ping what comes back to find a match.
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
Share on other sites

Thanks ;) It works

If any other one will ever need this, just use this code:

#include <Constants.au3>
#NoTrayIcon
$system = InputBox("System", "Enter the IP"&@CRLF&"This could use some time...", "")
If @error Then Exit

$run = Run(@ComSpec & " /c ping -a """&$system&"""", @SystemDir, @SW_HIDE, $STDOUT_CHILD)
While 1
    $line = StdoutRead($run)
    If @error = -1 Then ExitLoop
    If StringInStr($line, "[") Then
        $temp = $line
        $temp = StringReplace($temp, @CRLF, "")
        $temp = StringReplace($temp, @CR, "")
        $temp = StringReplace($temp, @LF, "")
        $temp = StringSplit($temp, "[")
        $temp = StringSplit($temp[1], " ")
        $temp = $temp[$temp[0]-1]
        ProcessClose("ping.exe")
        ExitLoop
    EndIf
Wend
MsgBox(0, "Name of the system "&$system, $temp)

Board search for other members:

internet protocol to name

Edited by Ghastly_MIB
Link to comment
Share on other sites

i use this:

$s_IP = '64.111.104.70'
ConsoleWrite(_INetName($s_IP) & @LF)


Func _RunSTD($s_p, $s_wd = @WorkingDir, $s_f = @SW_HIDE)
    Local $s_r = '', $i_pid = Run($s_p, $s_wd, $s_f, 2)
    While Not @error
        $s_r &= StdoutRead ($i_pid)
    WEnd
    Return $s_r
EndFunc;==>_RunSTD

Func _INetName($s_IP)
    $s_IP = StringRegExp(_RunSTD(@ComSpec & ' /c ping -a -n 1 -l 1 ' & $s_IP), ' .* (.*) \[', 3)
    Return $s_IP[0]
EndFunc  ;==>_INetName

its faster bc. of the "-n 1 -l 1" parameters.

Edited by w0uter

My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll

Link to comment
Share on other sites

MsgBox(0, "Name of the system "&$system, $temp)

Thank you! Minor change to last line:

MsgBox(0, "Name of the system " & $system, $temp)

The original threw an undeclared variable error, possibly because there was no space between the "&" and the "$"?

Edited by jefhal
...by the way, it's pronounced: "JIF"... Bob Berry --- inventor of the GIF format
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...