spanga Posted November 10, 2005 Posted November 10, 2005 (edited) Matching IP-adresses could be done by using Windows Ping command with the -a flag. But is there a better/faster way? I need to match 500 IP-adresses in my script so I guess the "Ping -a" method would be kinda slow. Anyone know of a better way to do this? Got this now: #include <Constants.au3> $IP = "64.111.104.70" $HostNameString = Run(@ComSpec & " /c ping -a -n 1 -w 1 " & $IP, @SystemDir, @SW_HIDE, $STDERR_CHILD + $STDOUT_CHILD) $HostName = StringSplit(StringTrimLeft(StdoutRead($HostNameString),25)," ") $HostName = $HostName[1] Allthough I'm still interested in a workaround the Run-function, as me nor some AV's dislike programs executing other programs. Edited November 10, 2005 by spanga
svennie Posted November 10, 2005 Posted November 10, 2005 For hostname to IP you can use TCPNameToIp from the beta (http://www.autoitscript.com/autoit3/files/beta/autoit/) But IP to Hostname? I will try to write a script for it but its not so easy... So i don't know if i can get it done. Sorry for my English, I'm Dutch... =DMedia UDFINet Adv UDF
MSLx Fanboy Posted November 10, 2005 Posted November 10, 2005 DOS has a nice DNS<->IP command, commonly known as 'nslookup' Just do a string manipulation with that, and viola Writing AutoIt scripts since _DateAdd("d", -2, _NowCalcDate())
SpookMeister Posted November 10, 2005 Posted November 10, 2005 also, autoit has its own ping command.. so you don't need to do a run at all. [u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]
GaryFrost Posted November 10, 2005 Posted November 10, 2005 also, autoit has its own ping command.. so you don't need to do a run at all. won't return the hostname tho. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
PerryRaptor Posted December 17, 2005 Posted December 17, 2005 If you have all 500 IP Addresses listed on a single line in a text file you could use FileReadLine(), pass it to the MS_DOS Ping command, and create a new text file with IP Address and the corresponding Hostname on each line. To decrease the time it takes MS_DOS Ping to return info add the "-n 1" switch to ping destination only once. I use such a script at work against thousands of workstations...takes about 2 - 3 minutes depending on network bandwidth. Make sure you add a feature for skipping over workstations that are offline.
PerryRaptor Posted December 18, 2005 Posted December 18, 2005 (edited) I put this in Scripts & Scraps...I.P. <> HostName Edited December 18, 2005 by PerryRaptor
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