Solved

Lock/logoff/disable Apple Mac if network cable unplugged

Posted on 2010-11-08
6
671 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
Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

 

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

Manage your data center from practically anywhere

The KN8164V features HD resolution of 1920 x 1200, FIPS 140-2 with level 1 security standards and virtual media transmissions at twice the speed. Built for reliability, the KN series provides local console and remote over IP access, ensuring 24/7 availability to all servers.

Question has a verified solution.

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

CocoaPods is the best way to manage library dependencies in iOS and OS X projects. By using cocoa pods there is no need of downloading the code from github and copying to your project. There are plenty of open source libraries now available with C…
This article outlines the struggles that Macs encounter in Windows-dominated workplace environments – and what Mac users can do to improve their network connectivity and remain productive.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

626 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