Avatar of Elthamtech
Elthamtech asked on

Lock/logoff/disable Apple Mac if network cable unplugged

Can anyone think of a way to lock/logoff/disable an iMac when the network cable is unplugged or it loses network connectivity?

Our students unplug the network cable in an effort to stop remote control and avoid managed preferences.

Running OSX Snow Leopard

Any help/ideas appreciated!

Apple NetworkingApple OSSwift Programming

Avatar of undefined
Last Comment

8/22/2022 - Mon


The above link shows you how to launch a process when network status changes.  You can then launch a script to do what you want using launchctl when the network status goes to down - and likewise restore everything when they plug it in again.

I am fairly new to the Mac world...Do you think you could please explain to me how that works?

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question

The second script says there's a syntax error somewhere on this line:

if [[ -z $1 ]]; then

Expected “,” or “]” but found unknown token.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.

if [[ -z "$1" ]]; then

All good - cheers I sorted that out. Took a while to get back to it,  but when I did your posts helped!