Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Applescript > Re: Can Applesc...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 11 Topic 1557 of 1612
Post > Topic >>

Re: Can Applescript tell if computer is online?

by Sander Tekelenburg <user@[EMAIL PROTECTED] > Jan 1, 2008 at 06:50 PM

In article 
<a80b8e5e-7e80-4bf2-8215-497ef86c0e51@[EMAIL PROTECTED]
>,
 biz@[EMAIL PROTECTED]
 wrote:

> I would like to write a conditional Applescript. The script would
> trigger itself every few hours and if the computer is not connected to
> the Internet I would like it to execute some code.

You'll need to define what constitutes "connected to the Internet". 
There is no way to ceck for that condition. However, if you define what 
it means to *you*, tere will be certain conditions that *can* be checked 
for. You could for instance check if the machines has a 
non-self-assigned IPv4 address:

property s_saIP : "269.254"
set s_IP4 to IPv4 address of (system info)
if s_IP4 does not start with s_saIP then
   -- we are connected to a network
   doStuff()
end if

on doStuff()
   -- do stuff
end doStuff

This assumes [1] that the Mac uses IPv4, [2] that is set up to be 
assigned an address (by a DHCP server), [3] that the network the Mac 
conects to is actually connected to/part of "the Internet".

For some reason (Tiger's) Standard Additions allows checking forthe 
primary IPv4 address only. If you use IPv6 or care about different 
network interfaces (Ethernet, Airport, FireWire, etc.), you'll prolly 
need to use do shell script.

> I have a bit of
> experience with AS but have no idea how to go about this one.
> Perhaps: "if Safari gets message "computer not connected to the
> internet" then execute this code"...
> Am I on the right track?

Yes, except that the Web, let alone Safari, is not "the Internet". It's 
perfectly possible to be connected to the Internet and yet not be able 
to fetch something off the Web.

-- 
Sander Tekelenburg, <http://www.euronet.nl/~tekelenb/>

Mac user: "Macs only have 40 viruses, tops!"
PC user: "SEE! Not even the virus writers support Macs!"




 11 Posts in Topic:
Can Applescript tell if computer is online?
biz@[EMAIL PROTECTED]   2007-12-31 19:22:34 
Re: Can Applescript tell if computer is online?
Sander Tekelenburg <us  2008-01-01 18:50:28 
Re: Can Applescript tell if computer is online?
biz@[EMAIL PROTECTED]   2008-01-02 05:38:29 
Re: Can Applescript tell if computer is online?
iterate4@[EMAIL PROTECTED  2008-01-03 00:00:15 
Re: Can Applescript tell if computer is online?
Jolly Roger <jollyroge  2008-01-02 18:20:28 
Re: Can Applescript tell if computer is online?
biz@[EMAIL PROTECTED]   2008-01-02 17:14:25 
Re: Can Applescript tell if computer is online?
Sander Tekelenburg <us  2008-01-03 14:56:24 
Re: Can Applescript tell if computer is online?
biz@[EMAIL PROTECTED]   2008-01-03 16:13:55 
Re: Can Applescript tell if computer is online?
Sander Tekelenburg <us  2008-01-04 05:58:56 
Re: Can Applescript tell if computer is online?
Jolly Roger <jollyroge  2008-01-03 23:14:15 
Re: Can Applescript tell if computer is online?
biz@[EMAIL PROTECTED]   2008-01-03 17:05:07 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat May 17 4:28:15 CDT 2008.