Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Lock/logoff/disable Apple Mac if network cable unplugged

Posted on 2010-11-08
6
Medium Priority
?
672 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 2000 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
Turn your laptop into a mobile console!

The CV211 Laptop USB Console Adapter provides a direct Laptop-to-Computer connection for fast and easy remote desktop access with no software to install.

 

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

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.

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…
Short answer to this question: there is no effective WiFi manager in iOS devices as seen in Windows WiFi or Macbook OSx WiFi management, but this article will try and provide some amicable solutions to better suite your needs.
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…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

722 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