tekhed Posted January 14, 2005 Share Posted January 14, 2005 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 Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 14, 2005 Share Posted January 14, 2005 Checkout Ping() in the helpfile. It's listed under Function Reference, misc. functions, for version .103. Ping() returns the roundtrip time in milliseconds. Link to comment Share on other sites More sharing options...
tekhed Posted January 14, 2005 Author Share Posted January 14, 2005 Awesome, thanks. I was still using .102, I've upgraded now. Will probably have more questions in a day or so... Thanks again, Mike Link to comment Share on other sites More sharing options...
PerryRaptor Posted January 14, 2005 Share Posted January 14, 2005 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) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now