Sign in to follow this  
Followers 0
Ghastly_MIB

IP to Net name

7 posts in this topic

Is it posible to convert a IP to net name?

Example:

192.168.1.2 TO \\Other_pc

74.25.36.96 To pc_name.internethost.com

??

Thanks,

Ghastly_MIB

Share this post


Link to post
Share on other sites



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

Share this post


Link to post
Share on other sites

How can I get that to my AutoIt Application?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

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

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  
Followers 0