Jump to content

GetIP()


Recommended Posts

If I run

#include <Inet.au3>
$PublicIP = _GetIP()
MsgBox(0, "IP Address", $PublicIP)

I get just a message box with IP address as expected.


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Ey,

I want get the IP adres, and save this.

This is no problem, I use the function _GetIP()

Still no problem... :whistle:

But if I look in the log file I see this:

But I want only see:

12.34.567.890

Thanks,

YoseMite

<{POST_SNAPBACK}>

that information is not being returned by the GetIP() call, it has to be something else in your code, or in the editor that you're using to open the log file...
Link to comment
Share on other sites

Go to Include\Inet.au3 and make sure your _GetIP Function is

Func _GetIP()
    Local $ip
    If InetGet("http://www.whatismyip.com", @TempDir & "\~ip.tmp") Then
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        $ip = StringTrimLeft($ip, StringInStr($ip, "<TITLE>Your ip is ") + 17)
        $ip = StringLeft($ip, StringInStr($ip, " WhatIsMyIP.com</TITLE>") - 1)    
        Return $ip
    Else
        SetError(1)
        Return -1
    EndIf
EndFunc
My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote]
Link to comment
Share on other sites

Hmm...

But Can I not only delete the tekst:

BLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<HTML>

<HEAD>

<TITLE>Your IP  Is

And save the IP?

<{POST_SNAPBACK}>

can you please tell us in which log file (path and name) you found that text?

Cheers

Kurt

__________________________________________________________(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 *

Link to comment
Share on other sites

When I run that with the addition of

#include <Inet.au3>

I get the IP address in the file as expected


Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Link to comment
Share on other sites

Script:

$file = FileOpen("listt.txt", 1)

$PublicIP = _GetIP()

FileWriteLine($file, ""& $PublicIP)

FileClose($file)

<{POST_SNAPBACK}>

This worked for me too!....You must be reading the wrong file...so

Try this

$file = FileOpen("listt.txt", 1)
$PublicIP = _GetIP()
FileWriteLine($file, ""& $PublicIP)
FileClose($file)

$file = FileOpen("listt.txt", 0)
$line = FileReadLine($file)
MsgBox(0,"test", $line)

you will see too

8)

NEWHeader1.png

Link to comment
Share on other sites

technically you COULD.... but it seems the best way to do that is to stop it from being printed in the first place....

<{POST_SNAPBACK}>

I got this problem too when i first ran the program, I don't know could be the website. since if you go to the website that is being called whatismyip.com your'll see it toggles with "your ip is" and " your ip - " where as in the function getip it's looking for " your ip is"

I modified to a more consistent site and made the function a little more dynamic to where you can choose any website that displays the ip including the braces

Func _GetIP_Dy($web,$strL,$strR)
    Local $ip
         
    TrayTip("Data Find", "Gathering Information", 2, 1)
;#comments-start
    Sleep(2000)
    If InetGet($web, @TempDir & "\~ip.tmp") Then
        TraySetToolTip ( "first")
        TrayTip("Operation Completed ", "Sucess", 5, 1)
        $ip = FileRead(@TempDir & "\~ip.tmp", FileGetSize(@TempDir & "\~ip.tmp"))
        FileDelete(@TempDir & "\~ip.tmp")
        
        $ip = StringTrimLeft($ip, StringInStr($ip, $strL) + StringLen($strL) - 1)
        $ip = StringLeft($ip, StringInStr($ip, $strR) - 1)    
        Return $ip
    Elseif _INetGetSource ( $web ) then
    TrayTip("Data Find", "First attempt failed" & @CRLF & "Attempting second options", 5, 2)
    Sleep(2000)
    
        $ip = _INetGetSource ( $web )
        $ip = StringTrimLeft($ip, StringInStr($ip, $strL) + StringLen($strL) - 1)
        $ip = StringLeft($ip, StringInStr($ip, $strR) - 1) 
        
    TrayTip("Data Find", "Sucess", 5, 1)
        Return $ip
    Else
        SetError(1)
        Return -1
    EndIf
;#comments-end
    
EndFunc;Function End >> _GetIP_Dy()

$strL = "<b>"
$strR = "</b>"
$web = "http://myipaddress.com/";"http://www.whatismyip.com"

$found_ip = _GetDataInner($web,$strL,$strR)

this will only give you the ip....I notice aswell with my firewall (zonealarm) the inetget didn't always work..it works fine on another machine, this is why i added inetgetsource which read the code the same why and retrieves the ip.

Link to comment
Share on other sites

I'm surprised there isn't a site out there that returns just the IP, no surrounding text or html formatting.

It's not like it's a hard thing to setup. Look here, I just put this on my site.

http://therks.com/ip

*Edit: By the way, I've never understood the need for this UDF, isn't this what the @IPAddress macros are for?

Edited by Saunders
Link to comment
Share on other sites

I'm surprised there isn't a site out there that returns just the IP, no surrounding text or html formatting.

It's not like it's a hard thing to setup. Look here, I just put this on my site.

http://therks.com/ip

*Edit: By the way, I've never understood the need for this UDF, isn't this what the @IPAddress macros are for?

<{POST_SNAPBACK}>

Nice Saunders...

Thats a much better way then adding more code or includes

8)

NEWHeader1.png

Link to comment
Share on other sites

  • Developers

*Edit: By the way, I've never understood the need for this UDF, isn't this what the @IPAddress macros are for?

<{POST_SNAPBACK}>

@IPAddress1-4 will return the IP adresses of the first four NICs your PC has.

_GetIP() will return the Public IPAddress on the internet. So when you use a DSL/Cable modem, it probably with use a LAT router and have Ethernet ports for multiple PCs.

The LAN switch will use some sort of public ip range on the like 192.168.x.x but this isn't the IP address you Dsl/Cable modem has on the Internet.

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...