Jump to content

Recommended Posts

Posted

The handy little script I have written is very dependant on the speed of my internet connection. Previously, I would simply change the sleep() command manually, but that isn't a very elegant solution. I would like my script to ping a server for a second or two, average out the timings, and then based on those timings, insert a variable amount of time in the sleep() function. I think I can cover everything except pinging the server, I haven't figured that out yet.

Thanks in advance,

Mike

Posted

Awesome, thanks. I was still using .102, I've upgraded now. Will probably have more questions in a day or so... :idiot:

Thanks again,

Mike

Posted

You didn't need version .103...You could have used the RunWait() and called the good old MS-DOS Ping.exe and filtered for the the data you wanted.

Here is a script that shows how to use the MS-DOS Ping.exe command; displays all of the information that is available; finally shows only the I.P. Address.

; Find_IP.au3

; Executes the MSDOS Ping command against a targeted Internet or Networked resource

; Ultimately returning only the I.P. Address of the target

; ----------------------------------------------------------------------------------

Local $strcomputer,$ip

$strcomputer = @computername

$strcomputer = InputBox("Display I.P. Address", "Enter the ComputerName for a remote PC, a web address, or press the {OK} button to show My_IP.", $strComputer, "")

; Ready to run the Ping, save the returned information to \Documents and Settings\[currentUser]\Find_IP.txt

RunWait(@ComSpec & " /C Ping -a -n 1 " & $strcomputer & "> Find_IP.txt",@MyDocumentsDir, @SW_HIDE)

$ip = FileRead(@MyDocumentsDir & "\Find_IP.txt", FileGetSize(@MyDocumentsDir & "\Find_IP.txt"))

FileDelete(@MyDocumentsDir & "\Find_IP.txt")

; Now lets look at all of the returned data...

MsgBox(0,"Returned Ping String [data]", "" & $ip)

; Lets search for the first occurance of "[.............]" and get rid of everything else

$ip = StringTrimLeft($ip, StringInStr($ip, "["))

$ip = StringLeft($ip, StringInStr($ip, "]")-1)

; Now, We will only return the I.P. address

MsgBox(0,"" & $strcomputer & " IP:", "" & $ip)

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
  • Recently Browsing   0 members

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