Re: Scripting in vain - please help :(
Re: Scripting in vain - please help :(
- Subject: Re: Scripting in vain - please help :(
- From: Sander Tekelenburg <email@hidden>
- Date: Sun, 4 Mar 2001 04:14:24 +0100
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
At 18:24 -0800 UTC, on 03/03/2001, Diego C De La Vega wrote:
>
[...] I want to create:
>
* A script that starts to run ONLY once the computer has automatically
>
reconnected onto the internet.
Assuming that's a PPP connection, and you're running at least OS 8.6, but
pre-OS 9.1, you might find my "SynchPPP" useful.[*] You'd still have to build
the script that grabs your IP address and mails it to you though. (Though I
believe there are some ready-made apps that can do this for you - check at
VersionTracker.)
Assuming you'd prefer to build the thing yourself:
>
The script then sends a copy of the
>
computers new IP address to an email address, which will be my WAP
>
email (ie. my mobile phone)
Essentially, and assuming OS 9.0.4, you could do something along these lines:
To find out if there is a connection:
(* if PPP connection: *)
set connectionState to state of (PPP status)
(* if Ethernet: *)
tell application "Apple System Profiler"
set connectionState to TCPIP status
end tell
Next, if there is a connection, you'll have to grab your IP address:
tell application "Apple System Profiler"
set myIP to TCPIP address
end tell
If you're on an 'old' OS version, you may need to use a third party Scripting
addition. For instance:
(* requires "Network Info" Scriptin Addition *)
set theInfo to get (<<event nNfonNfo>>) as list
set theIP to item 16 of theInfo
If you're behind a router, you'll have to ask _it_ for the IP address. That
would require understanding how to have a script talk to a remote Mac (for
which the syntax differs, depending on the type of network - AppleTalk or
TCP/IP.).
Last step then is to move "myIP" to a new e-mail message and have it mailed.
In Eudora, that would be something like:
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
You'd have to wrap the whole thing in an "on idle" handler, to have it
constantly monitor the state of your connection.
More specific help requires more info: What OS version? Is it OK to use third
party Scripting Additions or must it be vanilla AS? What kind of connection
to the Net - PPP? Ethernet? Direct, or through a router? If a router, what
router? Which mail client?
[...]
>
[...] It was hell trying to drive home, writing the new IP
>
address down and driving back to college, only to find out that the
>
Internet disconnected and reconnected under a new IP address :( [...]
Welcome to The Age Of Technology ;)
HTH
[*] SynchPPP will launch an app (of your choice) when a PPP connection is
established, and quit it when the connection is closed. See
<
http://www.euronet.nl/~tekelenb/software/index.html>.
-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <
http://www.pgp.com>
iQA/AwUBOqGypusywKfXgqKdEQInlACgwZ/9U+3cGPkwz+pSg+iS1ouaYN4AoORE
ibDoVR3wOv46LqAMxlBGENMN
=RzU1
-----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!"