get and mail current IP address (was Re: The Problem - IN DEPTH, please read carefully :))
get and mail current IP address (was Re: The Problem - IN DEPTH, please read carefully :))
- Subject: get and mail current IP address (was Re: The Problem - IN DEPTH, please read carefully :))
- From: Sander Tekelenburg <email@hidden>
- Date: Thu, 8 Mar 2001 17:28:24 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[You're really making things a *lot* more difficult than necessary by
changing the Subject in every message; using nondescriptrive Subject headers;
making them all _new_ messages instead of replies; sending half of the
information to the list, and the other half to me (and possibly to others)
personally.]
At 22:53 -0800 UTC, on 07/03/2001, Diego C De La Vega wrote:
>
Sander Tekelenburg <email@hidden>
>
last wrote:
>
> 1) How are you grabbing the IP address now?
>
>
I am grabbing it using the following script:
>
>
tell application "Eudora"
>
set currIP to setting 92
Ah. I didn't know this was possible :) However, since apparently it's giving
you problems, and someone else pointed out that Eudora tends to truncate (as
in "make it useless")) the IP address, it seems like a good idea to use
another way to get the IP address. See below.
[...]
>
> 2) What OS version are you using?
>
Mac OS 9.0.4
Then AFAIK this should work OK:
+++++ begin script +++++
property oldIP : ""
on idle
-- check if there is a PPP connection
set connectionState to state of (PPP status)
-- if there is a connection, continue
if connectionState /= "idle" then
-- get the IP address
tell application "Apple System Profiler"
set myIP to TCPIP address
end tell
-- check if IP has changed
if oldIP /= myIP then -- IP has changed. Do 2 things:
-- 1) store current IP, so we can compare later
set oldIP to myIP
-- 2) mail the new IP address
tell application "Eudora"
set theMessage to make new message at end of mailbox "Out"
set field "To" of (message "") to "email@hidden"
set field "Subject" of (message "") to "my new IP"
set body of (message "") to myIP
activate
queue theMessage
end tell
end if
end if
return
end idle
+++++ end script +++++
Paste into Script Editor and save as a 'stay open' applet (and check the
"Never show Startup screen" option). Your Startup Items folder would probably
be a good place for it.
In case you don't know about "on idle" handlers: that way the script will be
triggered to run every so many seconds (defaults to 30 seconds). So the idea
is to have this script open constantly, so it can monitor your Mac, notice a
change of IP address, and act upon it. (I'm assuming something else already
takes care of reconnecting your Mac when it needs to.)
Note that what you're trying to do can be tricky. The above should work, but
there are all sorts of circumstances (other applications running, errors that
may need to be handled), that are just too specific for your particular set
up to be able to hand you a fully customised foolproof script. You may have
to do some customising yourself, or hire someone to do it for you.
Having said that, the above should work. (If I made some silly mistake, I'm
sure someone on the list will point it out. (That's why it's best to keep
things on the list, instead of moving it to private e-mail where there is no
peer review.))
>
Please help, and try and keep your reply breif and to
>
the point. Lemme say this much. I would LIKE to know
>
more about AppleScript, but what I actually know is
>
another matter, ie. PLEASE don't confuse me with too
>
much jargon.
Aye sir. For this reason I tried to add useful comments to the script - read
them. However, it's impossible to not use jargon, and it's impossible to know
which jargon is "too much" for _you_. When it is too much, you'll just have
to ask about it. (Or, put another way: it's up to you to not allow yourself
to get confused by too much jargon ;))
HTH
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <
http://www.pgp.com>
iQA/AwUBOqezEusywKfXgqKdEQJERgCgz2bApBQo1t8BAsOerVEBq3/28mUAn3gv
H/smqwBGAkGuqw8vbLQuEBGD
=jsgp
-----END PGP SIGNATURE-----
--
Sander Tekelenburg, <
mailto:email@hidden>
Web site at <
http://www.euronet.nl/~tekelenb/>
Mac user: "Macs only have 40 viruses, tops!"
PC user: "SEE! Not even the virus writers support Macs!"