hshds Posted February 1, 2006 Share Posted February 1, 2006 Is there any way to get my WAN IP through Telenet or an other method directly from my router, without "leaving" the LAN? Some Internet providers change the public IP at non-regular time about once a day, and my application hangs after the IP changes. Therefore i must check every minute to eventually restart it. Until today i've done it through 1. GetIP(), and also through 2. ping myname.dyndns.org -n 1 > c:\wanipa.txt but this places unnecessary load on the external Internet servers. Also it is not optimal to open and close the command window every minute (more than 10000 times per day). I would like to do something like func _TelnetToIPWithPW($ip, $pw) ;; ip = address or name local $pid if not winExists(@comSpec) then ;; "E:\WINNT\system32\cmd.exe" $pid = run(@comSpec & " /c telnet " & $ip, "", @sw_show) while not winExists(@comSpec) sleep(50) wEnd winActivate(@comSpec) winWaitActive(@comSpec) send($pw) sleep(50) send("{ENTER}") sleep(200) endIf endFunc func _TelnetGetLog() local $text winActivate(@comSpec) winWaitActive(@comSpec) ; controlSend(@comSpec, "", "ConsoleWindowClass", "log -c", 0) ;doesn't work send("log -c") ;; get the router's call log sleep(1000) send("{ENTER}") sleep(400) for $i = 1 to 10 ;; a must, here send("{SPACE}") ;; more, more, .. sleep(50) next sleep(100) send("!{SPACE}") ;; alt-<space>, window menu sleep(200) send("es") ;; &edit>>&select all sleep(400) send("{ENTER}") ;; copy sleep(400) $text = clipGet() sleep(200) send("exit") sleep(100) send("{ENTER}") sleep(400) return $text endFunc func _TelnetGetWANIPA() local $text, $len, $wanipa, _ $startstring, $stopstring, $startindex, $stopindex $text = _TelnetGetLog() $startstring = "Own IP Address :" $stopstring = "Peer IP Address :" $len = stringLen($startstring) $startindex = stringInStr($text, $startstring, 0, -1) + $len $stopindex = stringInStr($text, $stopstring, 0, -1) $wanipa = stringMid($text, $startindex, $stopindex - $startindex - 1) $wanipa = stringStripWS($wanipa, 1 + 2) ;; strip leading & trailing WS ; msgBox(0, "_TelnetGetWANIPA() | len", $wanipa & " | " & stringLen($wanipa)) return $wanipa endFunc but in this case it seems i must communicate with an "active/open" command window and use Send() instead of ControlSend(), which does not work. Could anyone help, please? Link to comment Share on other sites More sharing options...
w0uter Posted February 1, 2006 Share Posted February 1, 2006 my linksys router gives me my ip in the status page:so i could just get the source of it. i my case it would be:http://username:password@192.168.1.1/Status.htmbut your company probly doesnt have a webinterface. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll Link to comment Share on other sites More sharing options...
hshds Posted February 2, 2006 Author Share Posted February 2, 2006 my linksys router gives me my ip in the status page:so i could just get the source of it. i my case it would be:http://username:password@192.168.1.1/Status.htmbut your company probly doesnt have a webinterface.Many thanks for your reply, wOuter.The problem persists. At my PC with W2K this method seems to not work. I have changed from empty user name to a non-empty one and tried your method in the following variants:1. http://username:password@192.168.1.1/doc/online.sht2. http://:password@192.168.1.1/doc/online.sht3. http://password@192.168.1.1/doc/online.shtbut none of these get me the wanted page, they simply make the IE browser to stay working.When i enter http://192.168.1.1/doc/online.sht (without credentials), i first get a dialog to enter my user name and password befor i get the page, but this dialog is exactly what i don't want. Is there eventually a way to escape or suppress the interactive credentials dialog? Link to comment Share on other sites More sharing options...
Confuzzled Posted February 9, 2006 Share Posted February 9, 2006 Have you tried entering the correct username and password configured in the router on your way into the correct screen with a second, intermediary screen? This would possibly be more acceptable than suppressing the security on the router. Link to comment Share on other sites More sharing options...
mikeytown2 Posted February 19, 2006 Share Posted February 19, 2006 This is old code i have from the forms, forgot where i got it expandcollapse popup;--------------------------------------------------------------- ; Find WAN iP-adresse ;--------------------------------------------------------------- $INI = @HomeDrive & "myip.ini" If FileExists($INI) = 0 Then IniWrite($INI, "URL", "1", "dynupdate.no-ip.com") IniWrite($INI, "URL", "2", "www.bpftpserver.com") IniWrite($INI, "URL", "3", "www.minasithil.org") IniWrite($INI, "URL", "URLS", "3") EndIf $POS = 0 $IP = 0 $URLS = IniRead($INI, "URL", "URLS", "") For $I = 1 To $URLS FileDelete(@HomeDrive & $POS + 1 & ".htm") Next While $POS < $URLS FileDelete(@HomeDrive & $POS - 1 & ".htm") $POS = $POS + 1 $IPTMP = @HomeDrive & $POS & ".htm" $URL = IniRead($INI, "URL", $POS, "") $IP = InetGet("http://" & $URL & "/ip.php", $IPTMP) $FS = FileGetSize($IPTMP) If FileExists($IPTMP) = 0 Then ContinueLoop If $FS > 16 Then ContinueLoop Else If $FS < 8 Then ContinueLoop EndIf If $FS <= 16 Then ExitLoop WEnd $FILE = FileOpen($IPTMP, 0) $LINE = FileReadLine($FILE) If $FILE = -1 Then $LINE = "Error when looking up IP. Maybe you're offline?" EndIf FileClose($FILE) FileDelete($IPTMP) FileDelete($INI) MsgBox(0, "", "WAN IP-address: " & $LINE) Email: POP3 & SMTP using SSL/TLS (OpenSSL)Email: IMAPEmail: Base64 & SMTP login & Send email direct to MX Server (thanks blindwig)Win: Hook Registry ChangesWin: Read/Write to Alternate Data Streams (ini example)Utility: GPS Distance Calculations, Vincenty and Haversine formulas; angles and elevationUtility: Dell Laser Printer (3000-5100) - Print LoggerUtility: Reset Router when Wireless Link FailsUtility: ImageMagick Batch jpg ProcessorVideo HCenc Batch FrontendVideo: *DEAD* YouTube Video Encoder (avs/avi to flv)Software On CD's I Like<<back|track3 Ultimate Boot CD for Windows SpinRite Ubuntu ophcrack 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