Solved

Lock/logoff/disable Apple Mac if network cable unplugged

Posted on 2010-11-08
6
670 Views
Last Modified: 2012-06-27
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!

0
Comment
Question by:Elthamtech
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 17

Expert Comment

by:sweetfa2
ID: 34091688
http://tech.inhelsinki.nl/locationchanger/

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.
0
 

Author Comment

by:Elthamtech
ID: 34098505
I am fairly new to the Mac world...Do you think you could please explain to me how that works?
0
 
LVL 17

Accepted Solution

by:
sweetfa2 earned 500 total points
ID: 34185921
The script in question does a lot of things, you won't need to do much of them.

You need to add the plist changes to your LaunchAgents directory.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
	"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>YOURInfo</string>
	<key>ProgramArguments</key>
	<array>
		<string>/Shared/bin/locationchanger</string>
	</array>
	<key>WatchPaths</key>
	<array>
		<string>/Library/Preferences/SystemConfiguration</string>
	</array>
</dict>
</plist>

Open in new window

You need to create a script (which the plist actually refers to - referring to a script you create).  The one in the example is overly complex for what you want.

The script just needs to lock the computer.

There is the script below taken from http://hintsforums.macworld.com/archive/index.php/t-30274.html
#!/bin/sh

# This script uses Panther's "Fast User Switching"
# to switch to the user whose username is specified as a command-line arg.
# If no arg is specified, it brings up the login window.
#
# Based on a script on the MacOSXHints site:
# http://www.macosxhints.com/article.php?story=20031102031045417

MENUEXTRAS="/System/Library/CoreServices/Menu Extras"
CGSESSION="$MENUEXTRAS/User.menu/Contents/Resources/CGSession"

if [[ -z $1 ]]; then
"$CGSESSION" -suspend
else
USERID=`id -u $1`;
if [[ -z $USERID ]]; then
exit -1;
fi;
"$CGSESSION" -switchToUserID $USERID
fi;

Open in new window

0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 

Author Comment

by:Elthamtech
ID: 34201827
The second script says there's a syntax error somewhere on this line:

if [[ -z $1 ]]; then

Expected “,” or “]” but found unknown token.
0
 
LVL 17

Expert Comment

by:sweetfa2
ID: 36469680
if [[ -z "$1" ]]; then
0
 

Author Comment

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

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Even though Mac OS X has been around for many years now, certain well-liked and eminently useful software apps never made the jump from Mac OS 9 to Mac OS X. Ever used Word Perfect for Mac? Version 3.5 was the last version, built for Mac OS 9. Who c…
A professional opinion on which Apple product to buy, and a tidbit about the WWDC.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question