Jump to content

IP Address/Emailing


Recommended Posts

I would like to create a script that gets my current outside IP address and sends it through outlook to a specified email address. I currently use UltraVNC to connect to my computers when I am away but if my ip address changes for some reason or another then I am screwed unless someone is at the house or work that can figure out the IP address and send it to me.

I am not sure exactly where to start. I know I will need to do something along the lines of:

$url = 'http://www.whatismyip.com'
Run(@comspec ' /c Start "" ' & $url,'',@swhide)
;I know the above opens my browser to the above location
;I would then need it to wait till done is shown of which I can get from other posts.
;Then I would need to copy and paste the IP address (This is the part I dont know how to do)

Thanks for everyone pointing me in the right direction. I have gotten my first script working. I was beta testing on a game and I wanted to send some information the Spy proved useful along with all of you help I successfully help the owner reduce the amount of macro'ing by prevenative measures.

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I would like to create a script that gets my current outside IP address and sends it through outlook to a specified email address. I currently use UltraVNC to connect to my computers when I am away but if my ip address changes for some reason or another then I am screwed unless someone is at the house or work that can figure out the IP address and send it to me.

It has nothing to do with AutoIt but you might want to have a look at www.dyndns.org. They've got a free service that allows you to have a simple name like jsthepatriot.mine.nu and if you run one of the clients to update the IP you don't need any emails for this but simply connect to jsthepatriot.mine.nu.
Link to comment
Share on other sites

I need this stuff too... I am working on it.

Thats what I did. I hope it helps.

Now, I have to disconnect

Dim $o-ip = -1, $n-ip, $pause
$pause = 20;Set the pause from a check and the next in minutes.

$pause = $pause * 60 * 1000
While 1
   $n-ip = _TakeIP()
   If @error Then
      Sleep($pause)
      ContinueLoop
   EndIf
   If $n-ip <> $o-ip Then
    ;;; Send Email
   EndIf
   $o-ip = _TakeIP()
   Sleep($pause)
Wend

Func _TakeIP()
   Local $ip
   If URLDownloadToFile("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

Edit: corrected a stupid mistake. The pause ( Sleep ) was after both checks, but between the two. :ph34r:

Edited by ezzetabi
Link to comment
Share on other sites

Wow okay. Glad to see so many replies. I havent been able to check back until now...

@sugi That wouldnt be bad if this was going to just be for my computers. (work and home) I have family that lives out of town and they would like me to be able to service their computers, but unless I could get in there and do the stuff I needed to do without having to bother them. I think this would also be useful for any of my clients that would want me to have access to fix their computers from else where. So the DNS was a good idea but not applicable in this case. Thank you for your timely response and good idea.

@Larry Thanks for the quick code. I suppose if it works I dont really need to know how it works, but I would like to know how it knows what out of the whole file is the actual IP address.

@ezzetabi Thanks for the more upgraded code. Are you going to use Blat? I was thinking it would be just as easy to make it just copy and paste it into a new Outlook email, although I think blat would go better if I am having customers from anywhere wanting this. I dont think it would be good that I require outlook to be setup and working. I will check into the blat more :ph34r: Thanks.

Thank you again to everyone. When I finally get the whole email thing finished I will try and find this thread so I can post the final code for any of those that come after.

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

@JS

Of course I am going to use Blat, to say it all I am working... But the boss toke me and I'll do not it today... to a indipendent UDF for sending email. Ready to any use!

Coping info in OutLook? Plain stupid, as you said the user must have a working Outlook and it may not be.

Instead Blat is GNU and command line based and always ready to work.

About graphical mail clients Pegasus Mail is sooo much better: www.pmail.com , check it.

About Blat. I have a small problem since it needs some registry key to works, so since I'd like leave nothing in the destination machine I have to create them in the fly, send the email and delete them.

(making a backup in the case the user uses Blat btw)

So it is not soo easy, but I'll do that. Tomorrow!

Bye

Edited by ezzetabi
Link to comment
Share on other sites

Ah interesting... I could have it use my website contact page yes? I know if they can use email they must have interenet. The only way around that would be to make it open the browser and goto mysite http://www.the-patriot.net/ then the contact us page... and enter the appropriate info. Or something to that nature. I will figure out something because I dont think I want to install and then uninstall a program unless it is easy. I will no doubt check it out and see how well I can integrate with it.

Thanks for everything so far,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Line 1 (File "C:\blablahblah\ip.au3"):

Dim $o-ip = -1, $n-ip, $pause

Dim $o-^ ERROR

Error: Unknown function name.

^^ is what I got when I ran the code from ezzetabi :-/ I am going to try Larry's code now and see what I get.

Thanks,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Hrm... I cant figure out what exactly is wrong with ezzetabi's script. It seems to be almost right but I cant quite put my finger on what is wrong.

Any help would be appreciated.

Thanks again for everything so far,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Okay I have it emailing, but I cant seem to get it to include variables. Please help if you know how to do this. I am using the bmail.exe as suggested above by This-Is-Me.

Let me know,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • Developers

Okay I have it emailing, but I cant seem to get it to include variables. Please help if you know how to do this. I am using the bmail.exe as suggested above by This-Is-Me.

Let me know,

JS

<{POST_SNAPBACK}>

post the portion of the script that is giving you problems, then its easier to see whats wrong...

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

post the portion of the script that is giving you problems, then its easier to see whats wrong...

<{POST_SNAPBACK}>

Duh! ::smacks head::

Dim $oip = -1 ,$nip,$pause
$pause = 20;Set the pause from a check and the next in minutes.
$pause = $pause * 60 * 1000

While 1
   $nip = _TakeIP()
   If @error Then
      Sleep($pause)
      ContinueLoop
   EndIf
   If $nip <> $oip Then
    Fileinstall("bmail.exe", @tempdir & "\bmail.exe")
    Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b $IP")
    Filedelete(@tempdir & "\bmail.exe")
   EndIf
   $oip = _TakeIP()
   Sleep($pause)
Wend

Func _TakeIP()
   Local $ip
   If URLDownloadToFile("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

Above is the whole code. Below is the actual problem area. (That way you can see what I am trying to do and why it isnt working).

Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b $IP")

It will send the email but the $IP isnt the ip address... HELP! :-P

Thanks,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • Developers

Duh! ::smacks head::

Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b $IP")

It will send the email but the $IP isnt the ip address... HELP! :-P

Thanks,

JS

<{POST_SNAPBACK}>

Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b " & $IP)

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

That produced an error that said the variable hasnt been declared?

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • Developers

That produced an error that said the variable hasnt been declared?

<{POST_SNAPBACK}>

well that means that $ip is not defined at the time the statement is executed...

just check you code logic to see if the $ip variable is set at the correct place..

Hint: $ip is a LOCAL variable for function _TakeIP() :ph34r:

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

well that means that $ip is not defined at the time the statement is executed...

just check you code logic to see if the $ip variable is set at the correct place..

Hint: $ip is a LOCAL variable for function _TakeIP()  :lol:

<{POST_SNAPBACK}>

I fixed it! WHOOHOO! :ph34r: I was just coming back to post that I got it taken care of when I read your post. I just used $nip (what was supposed to be there).

Thank you very much for you help :(. I am now going to see if I can ad a bit more in there hehe such as computer name that way I know who's ip is who's.

JS

PS I might be back!

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

Okay below is my full code. It works great. I just have one more thing I would like to happen and I am not sure how to make it do it.

Dim $oip = -1 ,$nip,$pause
$pause = 20;Set the pause from a check and the next in minutes.
$pause = $pause * 60 * 1000

While 1
   $nip = _TakeIP()
   If @error Then
      Sleep($pause)
      ContinueLoop
   EndIf
   If $nip <> $oip Then
    Fileinstall("bmail.exe", @tempdir & "\bmail.exe")
    Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b " & @ComputerName & $nip)
    Filedelete(@tempdir & "\bmail.exe")
   EndIf
   $oip = _TakeIP()
   Sleep($pause)
Wend

Func _TakeIP()
   Local $ip
   If URLDownloadToFile("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

More specifically I want the Computer Name and IP address to have a space in them. Refer to following code...

Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b " & @ComputerName & $nip)

Thanks for any help,

JS

Edited by JSThePatriot

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

  • Developers

Okay below is my full code. It works great. I just have one more thing I would like to happen and I am not sure how to make it do it.

Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b " & @ComputerName & $nip)

Thanks for any help,

JS

<{POST_SNAPBACK}>

Run(@tempdir & "\bmail.exe -s smtp.advances.net -t patriot@the-patriot.net -f admin@the-patriot.net -a IPAddress -b " & @ComputerName & " " & $nip)
:ph34r:

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...