Dirk98 Posted September 26, 2007 Share Posted September 26, 2007 Guys, I use the code below kindly given to me by some kind sole here to get my WAN IP: $oHTTP = ObjCreate("Microsoft.XMLHTTP") $oHTTP.Open("GET", "http://www.whatismyip.org/", False) $oHTTP.Send() $oIP = $oHTTP.ResponseText FileMove(@DesktopDir&"\CROWN.lnk",@DesktopDir&"\CROWN -"&$oIP&".lnk") Could you pleas add your lines to the script so that it would either: 1) if the service is not online just skip the whole part to the next function (now it just gets stuck and gives an error on no response); xor 2) if this site does not reply then try another link: "http://www.anothermyip.org/". Thank you! Link to comment Share on other sites More sharing options...
rambo3889 Posted September 26, 2007 Share Posted September 26, 2007 There is a function in the inet.au3 called _getip() which returns the ip cmyip.com gives you ( your wan ip) My Scripts:Radioblog Club Music DownloaderOther stuff:Fun movieIm serious read the help file it helps :PFight 'Till you drop. Never stop, You Cant give up. Til you reach the top Fight! youre the best in town Fight! Link to comment Share on other sites More sharing options...
Dirk98 Posted September 26, 2007 Author Share Posted September 26, 2007 There is a function in the inet.au3 called _getip() which returns the ip cmyip.com gives you ( your wan ip)Thanks rambo. Did you happen to read the code above? It does the same and a little more. My question was about different thing, but thank you for bumping it up. Link to comment Share on other sites More sharing options...
jvanegmond Posted September 26, 2007 Share Posted September 26, 2007 (edited) I'm just guessing some of this stuff, see what works.. $oHTTP = ObjCreate("Microsoft.XMLHTTP") If Not IsObj($oHTTP) Then Exit $oHTTP.Open("GET", "http://www.whatismyip.org/", False) $oHTTP.Send() If @error Then $oHTTP.Open("GET", "http://www.anothermyip.org/", False) $oHTTP.Send() If @error Then Exit Endif EndIf $oIP = $oHTTP.ResponseText FileMove(@DesktopDir&"\CROWN.lnk",@DesktopDir&"\CROWN -"&$oIP&".lnk") Edited September 26, 2007 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 26, 2007 Share Posted September 26, 2007 Couple of problems with this method: 1. At least here, www.whatismyip.org is returning my internal private address, not the external WAN address of the firewall/proxy. 2. If the access to www.whatismyip.org fails (I forced failure by changing the URL to www.whatismyip.or_), the entire 404 message is returned, not @error. 3. (minor nit picking) $oIP is not an object, just a string, so I changed it to $sIP just for convention's sake. $oHTTP = ObjCreate("Microsoft.XMLHTTP") If Not IsObj($oHTTP) Then Exit $oHTTP.Open("GET", "http://www.whatismyip.or_/", False) $oHTTP.Send() If @error Then $oHTTP.Open("GET", "http://www.anothermyip.org/", False) $oHTTP.Send() If @error Then Exit Endif EndIf $sIP = $oHTTP.ResponseText MsgBox(64, "Results", "IP: " & $sIP) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
jvanegmond Posted September 26, 2007 Share Posted September 26, 2007 Couple of problems with this method:1. At least here, www.whatismyip.org is returning my internal private address, not the external WAN address of the firewall/proxy.2. If the access to www.whatismyip.org fails (I forced failure by changing the URL to www.whatismyip.or_), the entire 404 message is returned, not @error.3. (minor nit picking) $oIP is not an object, just a string, so I changed it to $sIP just for convention's sake. Ok, you caught me. I was just guessing this. The underlying point of my post was for him to find it out on his own.. I should have told him to use the _MyIP function. ^^ github.com/jvanegmond Link to comment Share on other sites More sharing options...
Dirk98 Posted September 26, 2007 Author Share Posted September 26, 2007 Couple of problems with this method:1. At least here, www.whatismyip.org is returning my internal private address, not the external WAN address of the firewall/proxy.2. If the access to www.whatismyip.org fails (I forced failure by changing the URL to www.whatismyip.or_), the entire 404 message is returned, not @error.3. (minor nit picking) $oIP is not an object, just a string, so I changed it to $sIP just for convention's sake.On my end www.whatismyip.org is returning my WAN address outside my router. And I'm pretty much sure you are wrong thinking that it returns your internal private LAN address. It returns exactly your WAN address. Otherwise, I think you meant meant to say something else.Thanks for the code. Btw I believe you are right, it does not return an error but 404 message. Link to comment Share on other sites More sharing options...
ssubirias3 Posted September 26, 2007 Share Posted September 26, 2007 ... And I'm pretty much sure you are wrong thinking that it returns your internal private LAN address....Yikes!! Careful now... don't be so quick to make such claims especially with MVPs. Sure we're human and we can all make mistakes, but I'm pretty sure if PsaltyDS says something its good as gold. Maybe you overlooked what he said?? After all he did say from where he was testing, the site returned his internal address. Too many variables to consider and I would think he's the best qualified to say what he does or doesn't see . Then again maybe you know how the firewall(s) at his location are configured? Just food for thought. Link to comment Share on other sites More sharing options...
Dirk98 Posted September 26, 2007 Author Share Posted September 26, 2007 (edited) Yikes!! Careful now... don't be so quick to make such claims especially with MVPs. Sure we're human and we can all make mistakes, but I'm pretty sure if PsaltyDS says something its good as gold. Maybe you overlooked what he said?? After all he did say from where he was testing, the site returned his internal address. Too many variables to consider and I would think he's the best qualified to say what he does or doesn't see . Then again maybe you know how the firewall(s) at his location are configured? Just food for thought.Hehe, what would be a WAN address for him then? Unless http://www.whatismyip.org is inside his network. Edited September 26, 2007 by Dirk98 Link to comment Share on other sites More sharing options...
Nahuel Posted September 26, 2007 Share Posted September 26, 2007 Hey Dirk, I'm the one that gave you those lines. I chose http://www.whatismyip.org/ because it was a lot easier to get the text, since the site shows nothing else but your IP. This way, I can use the clean string returned by $oHTTP.ResponseText. Otherwise, it'd return all the source code of the site and you'd have to use something like $sIP=StringRegExp($oHTTP.ResponseText,"<html stuff>(.*?)</html stuff>).So just look for another myip site that stays online more often and see if you can clean the response text and get your IP using StringRegExp(). Link to comment Share on other sites More sharing options...
Dirk98 Posted September 26, 2007 Author Share Posted September 26, 2007 (edited) Hey Dirk, I'm the one that gave you those lines. I chose http://www.whatismyip.org/ because it was a lot easier to get the text, since the site shows nothing else but your IP. This way, I can use the clean string returned by $oHTTP.ResponseText. Otherwise, it'd return all the source code of the site and you'd have to use something like $sIP=StringRegExp($oHTTP.ResponseText,"<html stuff>(.*?)</html stuff>).So just look for another myip site that stays online more often and see if you can clean the response text and get your IP using StringRegExp().Thank you, Nahuel!!!I'm afraid either I put it wrong up there or... something else is wrong. Listen, I'm very HAPPY with your code that you gave me, thank you again. It works as requested originally. In this new thread I just asked for a few additional functions, like backup site, or to avoid the 404 message if no connection. PsaltyDS did it brilliantly, easy and very clear. Thank you again, PsaltyDS, my bows to you. Bows to all who posted here as well. Edited September 26, 2007 by Dirk98 Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 26, 2007 Share Posted September 26, 2007 On my end www.whatismyip.org is returning my WAN address outside my router. And I'm pretty much sure you are wrong thinking that it returns your internal private LAN address. It returns exactly your WAN address. Otherwise, I think you meant meant to say something else.Nope. My local address is in a 10.x.x.x/16 private address space that public facing routers will not route on the public internet. Period. I don't know exactly why our results differ, but what I get in $sIP is my local address. I also just used Firefox and IE to go to www.whatismyip.org and got the same thing. There is no way my computer is talking directly with www.whatismyip.org without going through my firewalls and proxies (plural on both). I suspect their web script at the distant end, on detecting some kind of exception, is just returning client information from the browser information it receives.BTW, cmyip.com does the same thing... and returns blank strings for my country and city. This network is a little more complicated than a cable modem and a 4-port Belkin... Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Dirk98 Posted September 26, 2007 Author Share Posted September 26, 2007 (edited) Nope. My local address is in a 10.x.x.x/16 private addressOk, I think that may explain it. But on the the othere hand, there's no way whaismyip can learn my LAN address and always returns ONLY the one OUTSIDE my router. All other similar services do the same.I don't really know if it is good or bad for you what you get.My LAN is behind a firewall and a router. I don't understand how those sites return your LAN address, unless your Firwall has some flexible settings and actually EXPOSES your local addres to the ROW. Maybe I miss something in the WAN definition? Also possible. But I may never learn what and how, of course, lol. Thanks. Edited September 26, 2007 by Dirk98 Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 26, 2007 Share Posted September 26, 2007 I don't really know if it is good or bad for you what you get....and I ain't tell'n! Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Nahuel Posted September 26, 2007 Share Posted September 26, 2007 Nope. My local address is in a 10.x.x.x/16 private address space that public facing routers will not route on the public internet. Period. I don't know exactly why our results differ, but what I get in $sIP is my local address. I also just used Firefox and IE to go to www.whatismyip.org and got the same thing. There is no way my computer is talking directly with www.whatismyip.org without going through my firewalls and proxies (plural on both). I suspect their web script at the distant end, on detecting some kind of exception, is just returning client information from the browser information it receives.BTW, cmyip.com does the same thing... and returns blank strings for my country and city. This network is a little more complicated than a cable modem and a 4-port Belkin... Oh I guess thigs are different in Mars 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