panter Posted February 9, 2007 Posted February 9, 2007 (edited) Hi, Im new in Autoit, Im writing a program which checks if server is Online. But IP of server which i need changes everytime when serwer go Offline. I got only www adres but ping function doesn't work with it (It return @error 4 even if serwer is online), so i need a function which will check what is the current IP of serwer. :"> global $Paused Do $var = Ping("217.82.52.176",250);need to get this IP from "mell.dyn.pl" If $var Then Msgbox(0,"Status","Serwer Online - Time:" & $var,5) Else Msgbox(0,"Status","Error numer: " & @error, 1) EndIf HotKeySet("{UP}", "TogglePause") HotKeySet("{Down}", "Out") until 1=2 Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('PAUSE',0,0) WEnd ToolTip("") EndFunc Func Out() Exit 0 EndFunc Got any ideas how to do that? I would be grateful for any help Sorry for my bad english Edited February 9, 2007 by panter
Uten Posted February 9, 2007 Posted February 9, 2007 I suppose nslookup and/or netstat could help you out. I have used tracert before but it is usually slow. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
/dev/null Posted February 9, 2007 Posted February 9, 2007 Hi, Im new in Autoit, Im writing a program which checks if server is Online. But IP of server which i need changes everytime when serwer go Offline. I got only www adres but ping function doesn't work with it (It return @error 4 even if serwer is online), so i need a function which will check what is the current IP of serwer. Got any ideas how to do that? I would be grateful for any help Sorry for my bad english Ping does not work with a DNS name?? It should. Please check if this works? $var = Ping("www.AutoItScript.com",250) If $var Then; also possible: If @error = 0 Then ... Msgbox(0,"Status","Online, roundtrip was:" & $var) Else Msgbox(0,"Status","An error occured with number: " & @error) EndIf oÝ÷ Ù8^Ø^è¬L#Íjg ÚºÚ"µÍÔÝ BÌÍÛ[YHHÔ[YUÒT ][ÝÝÝÝË]]Ò]ØÜÛÛI][ÝÊBYÜ[SÙÐÞ ][ÝÉ][ÝËÜB[ÙBSÙÐÞ ][ÝÉ][ÝË ÌÍÛ[YJB[Y __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
Uten Posted February 9, 2007 Posted February 9, 2007 (edited) Ping will not work if the ICMP service is turned off or the port (xx ?) is blocked by a firewall. As we speak about a server with dynamic ip I would think the port is blocked.TCPNameToIP is one of those functions that has passed unnoticed under my function radar. Thanks for that one..EDIT: Corrected echo to ICPM and port (25 ?) (duh ) to port (xx ?). Edited February 9, 2007 by Uten Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
panter Posted February 9, 2007 Author Posted February 9, 2007 I chceck the firewall before you wrote your post and you got right. It blocked the program and thats why it returned @error 4. I didn't thought firewall will block program becouse when i was entering IP in ping it worked O.K. Thanks for help And sorry for problems
/dev/null Posted February 9, 2007 Posted February 9, 2007 (edited) Ping will not work if the echo (?) service is turned off or the port (25 ?) is blocked by a firewall. As we speak about a server with dynamic ip I would think the port is blocked.@Uten: what you say about ping() is nonsense. ping() uses plain ICMP (no port 25 - which is SMTP/E-Mail, or anything !!). ICMP is mostly not blocked by network firewalls. Edited February 9, 2007 by /dev/null __________________________________________________________(l)user: Hey admin slave, how can I recover my deleted files?admin: No problem, there is a nice tool. It's called rm, like recovery method. Make sure to call it with the "recover fast" option like this: rm -rf *
jvanegmond Posted February 9, 2007 Posted February 9, 2007 I had this laying around... $ip = _GetUrlIP("www.google.com") If Not @error Then MsgBox(0, "Succes", $ip) Else MsgBox(0, "Fail", "The host was offline.") EndIf Func _GetUrlIP($url) Local $Read $PID = Run(@ComSpec & " /c ping " & $url & " -n 1 -w 500","",@SW_HIDE,2) While 1 $Read &= StdoutRead($PID) If @error Then ExitLoop Wend $a = StringInStr($Read,"[") If $a Then $Read = StringTrimLeft($Read,$a) $ip = StringLeft($Read,StringInStr($Read,"]")-1) Return $ip Else SetError(1) Return 0 EndIf EndFunc github.com/jvanegmond
Uten Posted February 9, 2007 Posted February 9, 2007 @Uten: what you say about ping() is nonsense. ping() uses plain ICMP (no port 25 - which is SMTP/E-Mail, or anything !!). ICMP is mostly not blocked by network firewalls.That's why I placed ? after both. Thanks for correcting me (I'm brain dead at the moment so please pardon me). When ping does not work ICPM is probably blocked or is there any other reasons ping would not work? PS: I will update my misguiding post to not confuse others that on day might read this thread. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
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