Jump to content

IP address and Ping


Recommended Posts

I have been trying to extract the ipaddress and ping from a command line and so far I have been trimming small amounts back and forth from each side ... There must be a quicker way to extract the data ??

$get = Run(@ComSpec & " /c " & "ping -n 1 -l 1 -w 110 " & $PC & " | find ""Reply from""", @ScriptDir, @SW_HIDE, $STDOUT_CHILD)

While ProcessExists($get)

Sleep(30)

WEnd

$StdOut = StdoutRead($get)

$ipdata = $StdOut

MsgBox(0, "Ping 1: " & $PC, $ipdata)

I'm thinking of something using stringregexp but unsure exacty how to use it...

Help would be great...

Link to comment
Share on other sites

Straight from the help file:

; Example 1
#include <inet.au3>
Dim $sResult, $sIp
TCPStartup()
$sIp = TCPNameToIP("hiddensoft.com")
$sResult = _TCPIpToName ($sIp)
If @error Then
    MsgBox(0, "_TCPIpToName()",  "@error = " & @error & @LF & "@extended = "  & @extended)
Else
    MsgBox(0, "hiddensoft.com realy  is:", $sResult)
EndIf

; Example 2
#include <array.au3>
#include <inet.au3>
Dim $aResult, $sIp
TCPStartup()
$sIp = _GetIP()
$aResult = _TCPIpToName ($sIp, 1)
If @error Then
    MsgBox(0, "_TCPIpToName()",  "@error = " & @error & @LF & "@extended = "  & @extended)
Else
    _ArrayDisplay($aResult, "Local Hostname(s)")
EndIf
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...