Applescript to check nearby networks

Discussion in 'Mac Apps and Mac App Store' started by HaraldBT, Mar 19, 2012.

  1. HaraldBT Guest

    #1
    Hi,

    I want to make an applescript that checks a list over networks, if none of those networks are nearby it will turn on password protection. I already have what the code for turning on password protection, but how can I check the networks?
     
  2. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #2
    What do you mean "it will turn on password protection"? If you're referring to your WiFi network, you should always have it protected with a secure WPA2 password, regardless of what other networks may be nearby.
     
  3. HaraldBT thread starter Guest

    #3
    It will turn on the password protection on my mac. That way, the password will turn on when I leave my home.
     
  4. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #4
    What do you mean by "password protection"? Your admin password? Your network password? You need to be more specific.

    How to maximise your MacRumors troubleshooting experience
     
  5. HaraldBT thread starter Guest

    #5
    I mean that you need the password to wake up the mac.
     
  6. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #6
    You can always have your Mac set to require a password to wake from sleep or screensaver. That has nothing to do with the presence of nearby WiFi networks.
     
  7. HaraldBT thread starter Guest

    #7
    I should probably describe this a little better: I want an applescript that checks what networks are nearby. If none of the the networks that are around at my home is nearby, it turns on password protection. I don't want to have password protection on my mac at home, but I want it to turn on automatically when I leave my home and open my mac. That way I keep the people I'm my class from playing Angry Birds on it.
     
  8. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #8
    Again, the presence of other networks has no effect on whether you use a password on waking from sleep or screensaver. The two are unrelated. Just go to System Preferences > Security and check or uncheck "Require password to wake this computer from sleep or screen saver", when you want to turn it on or off. What networks are present in the area has nothing to do with whether or not you use that feature. It's not related to networks at all. The networks that are near your home could be online or offline at any point, even if you're at home, which would have no effect on your system either way.
     
  9. HaraldBT thread starter Guest

    #9
    I know they're not related. I want an applescript to activate password protection if none of the usual networks are around.
     
  10. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #10
    That still doesn't make sense. That's like automatically turning on the air conditioning in your car if someone changes the TV to channel 4. One has nothing to do with the other. The presence or absence of networks is subject to change, even if you're at home. If none of the networks are available at any given point in time, that doesn't necessarily mean you're not at home. Also, having a script (even if you could create one) wouldn't activate until the computer was awake. So if you put your Mac to sleep at home, then took it to school and woke it up, it would wake without the password, because it would need to first wake up before it ran a script or could detect the presence of networks. Likewise, if you had the password enabled at school, put the computer to sleep, then woke it up at home, it would require the password, because it would first need to wake up to run a script or check the presence of networks. The whole approach is poorly conceived.
     
  11. HaraldBT thread starter Guest

    #11
    That is the point. When I come home, I would have to wake it up anyway before disabling password protection, and vice versa. And I know that the networks may change. I am not asking if makes sense or not, I'm asking if there is a way to do it.
     
  12. GGJstudios macrumors Westmere

    GGJstudios

    Joined:
    May 16, 2008
    #12
    No, there's not. As already stated, no script can run and no network can be detected in sleep mode.
     
  13. HaraldBT thread starter Guest

    #13
    Not in sleep mode, WHEN IT WAKES. I can easily use Sleepwatcher to run an applescript when it wakes.
     
  14. LaWally macrumors 6502a

    Joined:
    Feb 24, 2012
    #14
    /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s

    will list all available networks. I know it's possible to run the above command within a bash script and capture the output, but don't know about Apple Script. I'm thinking not.

    It seems to me that what you are proposing though is a solution in search of a problem. Why not just leave password on wake active all the time. Is that so inconvenient?

    I like to keep things simple.
     
  15. HaraldBT thread starter Guest

    #15
    Thank you, I might be able to somehow use this!

    It's not exactly inconvenient, but it's a little annoying to always have to use the password when I'm at home, and I always forget to turn it off.
     
  16. LaWally macrumors 6502a

    Joined:
    Feb 24, 2012
    #16
    Don't know if you keep regular hours, but you could set up your Mac to shutdown at a scheduled time every day.
     
  17. HaraldBT thread starter Guest

  18. Weaselboy Moderator

    Weaselboy

    Staff Member

    Joined:
    Jan 23, 2005
    Location:
    California
    #18
    It looks like Control Plane will do what you want. It can detect what network you are on and change many system settings based on which network you are using.
     

Share This Page