• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
RE: Scripting Airport? - how to
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Scripting Airport? - how to


  • Subject: RE: Scripting Airport? - how to
  • From: Charles Arthur <email@hidden>
  • Date: Wed, 10 Oct 2001 00:03:35 +0100

Hi...

At 11:07 am -0700 on 8/10/01, Alex Zavatone wrote:

>WHOA! Cool. So this implies that you can use applescript to see if the
>computer already has a live connection to the internet without forcing it to
>make a connection??

Yup. Script follows.

>Do you have to open the network database which is rather time consuming.
>Could the same approach be used with the network setup scripting app??

Not if you're sensible.

Here's the script:
--tested; watch for line breaks
(*
possible values of isConnected: status
Unknown/Disconnected/Connecting/Negotiating/Connected/Disconnecting
*)
set connectinglist to {"Connecting", "Negotiating"} -- when it's in the
midst of connecting

tell application "AirPort Scripting"
set thepower to power of card 1
if not thepower then -- if the card is off
set power of card 1 to true
delay 1 -- is a delay needed? Anyway.
end if

--now interrogate the network
set thestatus to PPPStatus 1 -- of your network/base station
set isConnected to (status of thestatus) as string
quit
end tell
--ending the tell wrapper here seems to be necessary; Airport Scripting doesn't
--seem to know how to do string work. This means that the tell wrapper has to
--be re-entered later if a connection is required.
if isConnected is "Unknown" then
activate
display dialog "Weird - don't know the status. Check card etc."
else
if connectinglist contains isConnected then
activate
display dialog "Already connecting" giving up after 5
else
if isConnected is "Disconnecting" then
activate
display dialog "Disconnecting - try again in a
moment." giving up after 5
else
if isConnected is "Disconnected" then
tell application "AirPort Scripting"
dial
quit
end tell
else
activate
display dialog "Already connected"
end if
end if
end if
end if
--end of script


Charles

http://www.ukclimbing.com : 1,000+ British crags, 350+ British climbing walls
- searchable by distance rock type, etc, with 5-day weather forecasts for
every one - plus maps, articles, news, and the New Routes database. There's
even a cool shop attached...


  • Prev by Date: URL Access Scripting and MacBinary?
  • Next by Date: Using the column type definition
  • Previous by thread: URL Access Scripting and MacBinary?
  • Next by thread: Using the column type definition
  • Index(es):
    • Date
    • Thread