June 2005 Archives

Intel Exec Explains Fair Use to Congress

| No Comments | No TrackBacks

There is an excellent article on why we need better copyright legislation than currently exists, and by that I don't mean "more restrictive": http://www.darknet.com/2005/06/story_the_tech_.html

In the above-linked article, the CEO of Intel explains that someday soon we're going to have video recorders at home that we'll want to use to stream TV programs to our car, boat, or vacation spot.  We'll want to do all kinds of fun and interesting things with the content we have.  But if the current DMCA laws stay in place, or we get tougher than that, we're going to lose a lot of good creative outlets.

It's a great read.

I Never Thought I'd See This...

| No Comments | No TrackBacks

Yesterday I went to the Conrad's store on Lane Avenue with my wife, who needed to pick up some Buckeye-related gifts for family members.  As I walked through the store, I saw the OSU logo on shirts, hats, pants, underwear, swimsuits, golf balls, golf tees, inflatable yard ornaments, etc.  It seemed a bit much.  I remarked to myself "I know one thing they won't have.  They won't have an OSU toilet!"  I was wrong, as the picture in the section below demonstrates...

Photo of OSU Toilet

When I saw this thing, I was stunned, both because I was sure such a thing wouldn't exist and because of the message it seemed to send.

Consider:  You need to relieve yourself, so you head for the bathroom.  You sit down on this thing and finish your business.  You've just "taken a ___(fill in your euphemism here)" on the Buckeyes.  Isn't that something like dropping a steamer on the 50 yard line at the 'shoe?

I imagine your Michigan-fan friends would enjoy this, though.  They could come out of the bathroom and exclaim that your team is "full of **it" and the proof is right there in your bathroom!  Perhaps that's who this is aimed at?

If you buy one of these, does it mean your team is "in the crapper"?

If it at least had a Michigan logo in the bowl I could see it being a humorous bathroom fixture. But as it is, it's just an insult to the team if you ask me...

Defeating The Targus DEFCON Ultra 1 Lock

| No Comments | No TrackBacks

I won't say where, but let's just say that I've had a fair amount of experience using the Targus DEFCON line of laptop locks.  When they are used, the number of laptop thefts seems to decrease pretty rapidly.  When I recently read an article on how a security expert (from security.org) defeated several of the more popular brands, including Targus.  It just so happened that on the same day I read that article, I had to disconnect a laptop that I had locked with a Targus DEFCON Ultra 1 lock (Model PA400 v3.0).  I couldn't remember what 4-digit code I'd used to secure the lock. 

I tried the "use every code I've ever used before" trick first.  I tried my voicemail code, my telephone extension, my office room number, my house number, the last four digits of my phone number, my cell phone number, my birth year, my birthdate in 4-digit format, my wife's extension number at work, etc.  It just wouldn't open.  I then moved into brute force mode (you know "0001", "0002", etc.).  I gave up around 150.  Then I remembered reading that article.

A few more Google searches turned up nothing other than references to a method using a thin piece of plastic, a ballpoint pen, or something they called the "tactile method".  I read another one where a post-it was used in place of a piece of plastic, so I tried that. No good. The ballpoint pen trick was for those with a cylinder keylock, not a combo lock.  That left the vague "tactile method" to try.  I knew "tactile" meant that it related to the sense of touch, so they must be saying that you'd be able to "feel" the right combination somehow.  Having nothing to lose, I tried figuring out some way to "feel" the right numbers.  After a few minutes, I decided it wasn't working.

Then I remembered being in college and being able to open dormitory mailboxes easily.  The method for doing that was relatively simple.  The box consisted of a combination dial and a lever that opened the door.  Press on the "open" lever with just the right amount of pressure and turn the dial in the direction you were supposed to turn to select the first digit of the combination.  When you felt the open lever "give" slightly, you'd just hit the first digit.  Turn in the other direction, maintaining pressure on the open lever, and you'd feel a "give" on the second digit.  Ditto for the third, at which time the door would open.

By pulling on the "fastener end" of the wire in the device and pressing the red "unlock" button while turning the right-most digit (looking from the top of the unit down), I felt a "give" around a particular digit, so I left it there, and started with the one next to it, and so on.  It wasn't long before I had discovered all 4 digits of the combination that I'd forgotten.  In fact, from the moment I started the "tactile method" described here until I found the combination wasn't more than about 2 minutes.  Scary.

The following Visual Basic 6.0 (VB6) subroutine will show you how to write data into Microsoft Excel spreadsheet cells from your program.

As with all my sample code, it's provided as-is without warranty or support.  Use at your own risk.

VBScript Function to Determine if a Registry Entry Exists

| No Comments | No TrackBacks

The following function, when called with the path to a Windows Registry entry, will attempt to tell you if that entry exists in the Registry of the system it's running on.

For example, you might call it as follows:

theEntry = "HKLM\Software\Microsoft\Internet Explorer\Main\Start Page"
if regEntryExists(theEntry) then
   msgbox "That Registry Entry exists."
else
   msgbox "That Registry Entry doesn't exist."
endif

The function returns a true or false Boolean response.  True if the Registry entry exists, False if it doesn't.

VBScript "Sleep" Function

| No Comments | No TrackBacks

Sometimes during a VBScript, you need the system to "go to sleep" for a little while so that you can wait for something to happen.  For example, you might want to start a process running and give it 30 seconds to finish before you do something else, or you might want check a given directory for a file every minute or so. 

This VBScript function returns an array when given a line of tab-delimited text.

To use it, write a line of code like the following:

Dim theArray()
theText = "something tab delimited"
theArray = tabsplit(theText)

As with all my script code, this is provided as-is without warranty or support.  Use at your own risk.

Send an Email Via Outlook from VB or VBScript

| No Comments | No TrackBacks

The VBScript code below will send an email message through Microsoft Outlook (the Exchange Server version, it probably won't work with Outlook Express) when you call it from your script.  Using this subroutine you can customize the subject and content of the mail message as well as its recipients.

To use it, the syntax is:

  mailThisMessage toAddress, bccList, ccList, subjectLine, theMessage

where:

toAddress is the email address you want to send the message to (use ";" for multiple addresses)

bccList is the list of email addresses you want to "bcc" the mail message to via Outlook

ccList is the list of email addresses you want to copy the mail message to via Outlook

subjectLine is the subject line of the message you're sending via Outlook

theMessage is a text field containing the actual message you want to send, in HTML format, via Microsoft Outlook mail

As with all my scripts and code, this is provided without warranty or support.  Use at your own risk.

OS X Script to Create a User from the Command Line

| No Comments | No TrackBacks
If you ever need to set up a local user account on a remote machine from the command line, this script can help.  It will allow you to create a local account on the machine you're running it on, whether it's local or remote.  

To use the script, login as root and run the script.  Follow the prompts and when it's finished, the account will be created on the screen.  If you tell the script to create the account as an administrator account, it will add the user to the admin group on the machine.

As to what this script is doing behind the scenes, it's essentially this... First, it's prompting the user for the information needed to create the account, such as the short name for the account, the first and last names of the user, a user ID number, and an initial password.  Then it encrypts the password provided using openssl encryption.  After that, it asks if the user needs administrator rights to the machine. 

Based on the above information, the script then calls the NetInfo utility (niutil) to create the user account in the system.  If the user is to be an administrator, it adds them to the appropriate group in NetInfo. 

If this is all the script did, you'd only have a "partially working" account on the system.  In order for the account to be "fully working" the newly-created user needs a home directory in the "/Users" directory on the boot drive.  Normally, when a user is created in the GUI, OS X pulls a "clean" home directory from the "/System/Library/User Template/English.lproj" (for systems running with the English language at least) directory and copies it into the "/Users" directory in a directory matching the account's "short name".  The last portion of the script replicates this behavior and changes ownership of the newly-created user directory to the newly-created user.  This should be all that is necessary for the user to login to the Macintosh.

While this script has been tested on OS X 10.3.9 and is believed to work properly, no warranty is expressed or implied.  If this script works for you, fantastic!   If not, I accept no responsibility for what happens.  By downloading and using the script, you accept all responsibility for any consequences from using it.

A.R. Robaina Familiares Cigar Review

| No Comments | No TrackBacks
A.R. Robaina Familiares
Cigar BurningThe 2 Guys Smoke Shop in Salem, New Hampshire recently sent me an email offer on the A. R. Robaina line of cigars.  They caught my attention because they contain 40% pre-embargo Cuban tobacco.  I've never been able to bring myself to pay the rather high prices charged for pre-embargo Cuban cigars, so I figured this is about as close as I'm ever going to get.

In addition to the 40% Cuban long filler, the cigar boasts a Cuban-seed Ecuadorian wrapper from the 2000 crop.  The wrapper is a very rich dark brown with fine veins.  Its construction is very firm.  Unlit, the cigar has a wonderful smell.  A draw through the punched but unlit cigar was easy and had a hint of spiciness to it.

Once lit, I found that I was in for quite a treat.  The aroma of the smoke was by far the most pleasant I've ever smelled.  It had what I can only describe as a perfect "classic cigar" smell.  The flavor was a rich medium-bodied one.  The smoke was very creamy white and (if I had the talent to do so) would probably have blown wonderful smoke rings.  Keep it away from your eyes, though.  It burned mine like no other smoke ever has.  It also made my head swim more than any cigar ever has.  Felt like I'd just pounded about a half-dozen beers by the time I was about a half to two-thirds of the way through it.  Wow...

The cigar burned evenly.  The ash was firm and medium gray in color.  It stayed on the cigar until I tapped it off.  I don't think it would have stayed on if allowed to grow to about an inch. 

If this is what a "real" Cuban cigar is like, I understand why people love them.  I enjoyed everything about this one and can't wait to smoke the other one I bought.  I'm even considering picking up a few more.  (BTW, 2 Guys has a really good price on them that puts them in just about everyone's price range. I don't know if I'm allowed to tell what that price is, since they can't, but let's just say that an "Abe Lincoln" and a couple of coins should get you a single, before shipping.)

On a 1-10 scale, with 10 being excellent, this one has to be about an 8.75!  Definitely recommended.

Enhance Your Firefox Browsing

| No Comments | No TrackBacks
I've been a Firefox user for a while now. This article contains my accumulated tips for improving Firefox speed, reliability, security, etc.  Where possible, exact step-by-step instructions are provided.  As with any tips you get off the Internet, no warranty is provided with these.  Use them at your own risk.  I don't think any of them will make Firefox inoperable, but I don't claim they won't, either.

Cohiba Red Dot Pequeno Cigar Review

| No Comments | No TrackBacks

As part of a trade with a member of the CigarBid.com forums, I received a Cohiba Red Dot Pequeno cigar.  Yesterday, while waiting on my step-son to finish playing 9 holes at a nearby public golf course (Wilson Road for those of you who know or care), I lit up the cigar.  (Since then, I purchased a 6-pack tin from CigarBid.com and took some better photos for the article.)  Here is a review of my experiences...

Need for Speed Underground 2 Promo Code

| No Comments | No TrackBacks
I recently purchased Need for Speed Underground 2 for the PC from EB Games. It came with a promo code that was supposed to go to those who pre-purchased it, but they included it with my copy anyway.

According to the sheet that comes with the game "Start the game in career mode and receive an extra $1,000 in game funds to buy parts and upgrades for your car. Or, start a game in Quick Race mode and get access to the Mazda RX-8 and Nissan Skyline before your competitors have a chance."

To view the cheat codes or promo codes for this game, click the link below to view the full article (if the codes don't already appear below)...

OS X System Optimization Script

| No Comments | No TrackBacks

The script below combines the functions of several others on this site into one "optimization" script.  It cleans up the various caches, updates prebindings to improve system performance, repairs permissions on the startup disk, and reboots the computer.

It must be run with administrator privileges in order to work properly.

As with all my scripts, this one is offered "as is" without warranty or support.  If you choose to use it, you accept all liability and responsibility for whatever might happen to your system (good or bad).

OS X Script to Re-Prebind the System

| No Comments | No TrackBacks

A good description of what "re-prebinding" is and why you would want to do it appears here:

http://macusertalk.com/discuss/lofiversion/index.php/t119.html

The basic gist of it is that your applications may launch faster and the system may run better overall if you periodically re-prebind things.

The script below, when executed with administrator permission, will re-prebind all the software on your boot drive, potentially improving performance.

The script was designed for and tested on OS X 10.3.x and may or may not work with earlier or later OS X releases.  As with all my scripts, by downloading and attempting to use them you agree to accept all responsibility and liability for whatever may happen.  That means if you run this script and your system wipes its hard drive, catches fire, and burns down your entire city (highly unlikely) or anything else goes wrong, you agree that I'm not responsible.  I don't support or warranty these scripts in any way. I just share them here in the hope that they'll help others.

Customizing Default User Preferences in OS X

| No Comments | No TrackBacks

(The following article is intended for experienced and knowledgeable system administrators only. If you find parts of the discussion below contain verbs you don't understand, techniques that you aren't comfortable with, etc., I recommend NOT attempting to follow these instructions or use the provided script. This technique requires some pretty-advanced skills and experience.)

What is this article about?

As an OS X system administrator, you may want to change the default appearance of OS X the first time a new user logs into it. For example, you might be writing lab instructions for students and want a particular file to be "guaranteed" to be in their home directory or on their desktop when they first login. You might want to be sure that certain applications are in everyone's Dock, or avoid having to require users to enter a serial number the first time they launch a particular program. Whatever your reasoning, the bottom line is that you want to change (from Apple's or some third party's defaults) the way a user's OS X interface or applications behave from the first time they login. There are two ways you can do that.  The first is to create an account for the user, login as that user, and make the changes.  That's the safest and best way to do it, but if a user logs in who doesn't have a local account on that machine (e.g., they authenticated through Active Directory or UNIX NIS), they won't have your customizations.  But there's another way that "doesn't care" if there is a local account on the system already, that will get the right set of customizations in place for every user who ever logs in (local or via the network).

In this article, I'll tell you how I did that at my company, and how you can do it, too.  But, please, before you make the decision to go down this path, read this entire article.  If you follow my instructions here carefully and test the changes you make thoroughly, you shouldn't have too many problems.  If you miss a step or don't test something, I can practically guarantee that you're going to have problems - and some of them you might not see for a week, a month, or more. 

Before you can understand the procedure for doing this, you need to know a little about how OS X stores a specific user's preferences, and how it decides what those preferences should be to begin with. Once you know that, you'll know much of what you need to know to be able to customize those defaults (but I promise you, you won't know everything you need to know).

How do initial user preferences get set by OS X?

When a local user account is created on an OS X system, OS X automatically creates a directory for that user in the "/Users" directory.  If you don't authenticate locally, you may have a script in place that creates that initial user directory for the user.  That initial user directory is where Apple sets the "default" user preferences for everyone on that particular machine.

For example, when a local user with the short name of "Fred" is setup on the system, a "/Users/Fred" directory is created on that computer. Inside this directory are files OS X creates to keep track of Fred's favorite settings (e.g., icon or list view in the Finder), files that OS X applications use to keep track of what Fred likes (e.g., his word processor's default font setting or his dictionary words), settings saved by his third-party software (like Microsoft Office), and files he's placed in his home directory. But if there wasn't a "Fred" directory before Fred's account was created, how did it get there?

There are two ways files can "automatically" end up in Fred's home directory. One way is that the files are created when Fred first tries to execute a particular application (for example, after the first time he launches Adobe PhotoShop). The other is that they were put there by OS X before Fred logged in, to provide a "base" environment for him to work in. That "base" environment comes from the files stored in the following directory:

   /System/Library/User Template/English.lproj

(This assumes that you're using the English settings in OS X. If you're using another language, your defaults may be coming from one of the other subdirectories in the "User Template" directory.)

When a new account is created, OS X copies the files in the above directory into a new subdirectory under "/Users". This creates the new user's initial "sandbox" environment.

So, the theory on which this article is based is that by modifying the contents of the above directory ("English.lproj") we can customize what new users will see when they first login to OS X.  Sounds very straightforward, right?  It's not.

So what's the catch?

Earlier, I mentioned that being thorough and careful in your testing is critical. While it is true that many kinds of customizations are indeed as simple as adding or replacing files in the "User Template" directory, some are not. Some customizations may not even be possible at all, without some major "hacking" at the files in that directory. You have been warned!

There are several things that can go wrong here, and I'm probably not going to be giving you a comprehensive list of the things I've seen go wrong because I can't honestly remember them all. Even if I remembered all the issues I saw, you may have different software or configuration issues in your environment that I haven't seen, and I can't warn you about something that didn't happen to me. Again, you have been warned.  Testing the changes after you make them is absolutely critical.  Testing the new user template thoroughly after any change is equally critical.

At a high level, all the problems boil down to one thing: There are some preferences files that store information which identifies the original user who made the customization. If those same preferences files are given to another user, when the user tries to do something involving the data stored in that preferences file, OS X will try to modify the files belonging to that original user. Since OS X's security will generally prevent one user from screwing around with another user's files, this new user is going to get security warnings, application errors, crashes, lock-ups, and other unpleasant results from our customization attempt. The only way you can be sure that this doesn't happen is to test, test, and re-test. Even if you test very thoroughly, odds are that your users are going to find something you didn't expect that isn't working. Mine did, and still do occasionally.

What's the procedure?

The process is pretty straightforward, really. First, begin with a Macintosh that you can afford to "trash" if need be.  That is, don't do this with a Mac whose configuration you can't easily and quickly put back to normal.  It is possible to render a machine partially (maybe completely) unusable by performing this little "trick".  Again, you've been warned...

You will begin by logging in as root or administrator and locating the following directory on the boot disk:

  /System/Library/User Template/English.lproj

Having found that directory, you should back it up somewhere on another drive, another partition, etc. This way, if you really screw things up badly later, you can restore this directory from the backup and start over again. My first time trying this, I had to start over more than once. Consider that another warning!

Next, while logged in with administrator privileges, create two new accounts on the Mac. One should be called "default" (because my script below depends on that particular name... if you change the name, change the script accordingly or it won't work). The other can be any name you like, but I suggest using the name "test" to keep things consistent with these instructions.  Neither of these accounts should have administrator privileges.

You will notice that there is now a "default" directory inside the "/Users" directory on the boot disk. This directory contains the base settings that OS X has provided for a new user, customized slightly for the new user called "default".  This "default" user directory is where we'll make the customizations that we'd like all our users to have.  Once we've made the customizations we want to make, we'll copy this "default" user directory over top of (and replacing the matching files within) the "/System/Library/User Template/English.lproj" directory.  When a new user is created, that user will (as normal) get a copy of the "English.lproj" directory which contains our customized settings.  In this example, we'll use the "test" user to simulate someone logging in for the first time and getting our new settings.  Later, ANY first-time user will get the new settings.
With your environment setup as recommended here, it's time to begin. Login as "default". Make all the changes you want to make for your users. For example, change the desktop pattern to the company logo, adjust the default Finder views to "list", turn on the screen saver, etc. When you have configured the "default" user's environment to your standards or needs, log out.

Log in as "root" (rather than admin, because it will work more easily for this process). Run the script provided below to overwrite the system's base "User Template" with the files from "/Users/default". Now, locate the "/Users/test" directory if it exists. Delete the "test" directory, leaving the rest intact. Log out as root. Login as "test". You should see that things look a lot like they did when you were logged in as "default". (If not, I've given you bad instructions here and what you should do is log back in as root, delete the "test" account, then re-add the "test" account. It's been a while, and I'm working from memory here.)

At this point, you should try everything you possibly can. Browse files in the Finder, click on all the shortcut buttons in the Finder window, change system preferences for things, etc. When you've done all the "OS X" stuff that you can, start testing the applications. For example, launch Safari, add a bookmark, remove a bookmark, change the default home page, download some files, etc. Continue for every other application and function on the system that you think your end users might possibly ever use. You're going to find that some things don't work. I can almost guarantee that. What do you do if something doesn't work?  Cry. No, just kidding. Don't do that. You might get the keyboard wet, and that could cause other problems.

Here's where you become a sort of "Sherlock Holmes of OS X". The "crime" you're investigating here is that the application (or part of OS X) that is misbehaving is doing so because in one of the many preferences files in "/Users/test", some piece of information is telling that application that it needs to be modifying something (a file or directory) that belongs to "default" rather than "test". Since OS X's security won't let that kind of activity take place, the application is behaving oddly for "test" but quite normally when "default" is logged in. Your job is to figure out which file(s) in "/Users/test" are causing this problem.  (If you ignored my instructions earlier and setup the "test" account as administrator, some things will work normally that shouldn't, because an administrator COULD modify some of "default's" files.)

I recommend starting in the "/Users/test/Library" directory to find your culprit (but it may not be there, so branch out if you have to). Most likely it will be a file in the "Preferences" subdirectory whose name ends in ".plist" but it could be elsewhere. The files in this directory are all given names that should clue you in to the fact that they relate to the application that's misbehaving. For example, in my own Preferences directory there is a file named "com.microsoft.Word.plist". If I was troubleshooting a Microsoft Word problem, I'd suspect this file first, especially if it shows a modification date that is around the time I setup my Word preferences in the "default" account.

To see if this is the file where the problem exists, I'd log in as "root" and move that file from "/Users/test" to somewhere else. Then I'd log back in as "test" and try doing the thing in Word that didn't work. If it works now, I've found the right file. What you do next is going to be one of the following:

  • Don't include the file in the User Template. In this case, you'll adjust the script below to delete that file from "/System/Library/User Template/English.lproj" after it has synchronized with the default directory. This will ensure that you don't later on forget that this file is a problem and include it for other users.
  • Fix the problem within the file. This is a lot harder, and maybe not even possible depending on the setting that's at fault. Open the file in TextEdit. It will often (though not always) be in somewhat-readable XML format. You may find as you scan through the contents of the file that there is a line in there that references "/Users/default" or something that points to a resource "owned" by default. In some cases you can delete these lines from the file and the preference gets filled in with the name of the user who just logged in when they try to launch that application. If so, you'll need to make a note for yourself that you have to delete such-and-such line from such-and-such file to make the application work for other users.
  • Fix the problem by merging some preferences from the "default" directory plist file with those in the backup of the original "User Template" directory. In other words, you might find that by adding a line or two from the original Word preferences file in the backup of the original "User Template" directory you can create a new file for the new "User Template" that works for all users.
  • Use the file from the backup of the original "User Template" that you made before changing anything. (Some applications may require a "blank" preferences file to be there the first time they're launched.)

If you haven't guessed, the second and third options above are a lot of work, and fraught with error. Plus, to implement them properly you need to document what you did, adjust the script below to automate that in the future (if you can), etc. I found it to be more trouble than it was worth to me in nearly all cases, and I went for the first option (or the last, if that didn't work).

Each time you think you've fixed a problem, I recommend that you delete the "test" directory in "/Users" and try the same test again. Then test everything else you can think of in that same application. You may find that in fixing this issue, you've created another. I don't have any good scientific way to figure out what works and what's broken other than to test and re-test.

So there you have it. That's how you setup a profile to be customized, but the same for all first-time users.

I found something you missed!

If you discover some changes that should be made to my script, perhaps you'll drop me a line and suggest how I can improve it. If you have specific tips on how to correct problems with a given application, I'm interested in those, too. I'll add the information here for others to use if you share it with me. (Since this web site isn't my full-time job, don't expect me to perform instant updates, but I will get around to it as soon as I can.)

Disclaimer:  As with all my scripts and articles, this has worked for me on the systems I administer. Carefully implemented and tested, it ought to work for you in many cases as well. But I provide this information and the script below on an "as is" basis. If it works for you, great! If it doesn't, you agree that by using the information or script that you've assumed all liability and responsibility for what happens to you, your network, and your computers (and anything else I've forgotten that might be affected).

OS X Script to Repair Permissions on All Volumes

| No Comments | No TrackBacks

This script, which can be executed from a command line or via cron, will attempt to repair permissions on all the drives attached to the system.  If, for any reason, permissions can't be repaired on a given volume (e.g., permissions are turned off on that volume), it will generate an error and move on to the next volume.

This script has been tested on OS X 10.3.x.  It may work on earlier or later OS X versions, but I don't warrant that.  By choosing to use this script, you assume all responsibility for the outcome (good or bad).  I do not support this script but will except bug fixes if you make any, or improvements.

OS X Script to Remove .DS_Store and .localized Files

| No Comments | No TrackBacks

By default, Mac OS X drops a lot of ".DS_Store" and ".localized" files on systems.  These files don't need to be a part of your backup and recovery process.  They can also be the source of some problems in the Finder (or so I am told).  This script attempts to locate and delete all the ".DS_Store" and ".localized" files it can find on your boot disk.  It can be run from the command line or as a cron task.

Although I've tested this script and believe it functions as designed on Mac OS X 10.3 systems, I provide it "as is" without warranty or support.  If you choose to try this script on your own Mac system, you assume all responsibility and liability for what happens (i.e., if it wipes out all your data, that's not my fault or my problem, and all I will do is apologize for your loss). 

OS X Script to Lock Down Non-Work Applications

| No Comments | No TrackBacks

Our IT department has a policy that all non-work-related software (especially games) be deleted or locked down in some manner so that employees aren't tempted to be doing non-work activities during the work day.

In my early OS X testing, I tried just deleting the games that ship as part of OS X.  This had the unintended side effect of "breaking" the software update process.  When OS X tried to update wireless networking components or iPod software and couldn't find it, it complained.  Since OS X is a UNIX system, I realized that I could achieve the company's policy goals by simply setting up a cron script that changed the UNIX permissions on the relevant files so that end users could not access them.

You might ask why this can't be a "one time" deal.  Good question. The reason is that the first time you repair permissions on a system locked down in this way, OS X dutifully restores the original permissions for you and would allow the users to run the prohibited software.  While I could trust that I'll remember to lock the applications down every time I run a disk or permission repair, I'm not the only one in the office doing this kind of administration work.  And my memory's not that great anyway.  So I set this script up as a cron task and have it lock down those applications my users aren't permitted to use.  That way, even if I forget to run this script after doing a permission repair, cron will see that the files are locked down for me after work tonight. 

Since your organization's (or household's) policies may differ, you'll need to modify the script below to suit your specific needs.  I will not provide assistance doing this, but I think if you look at the code below and have any scripting experience, you'll easily see what to do to adjust the script to your needs.

As always, I provide this script "as is" without warranty or support.  If it works for you, or you can make it work for you, great.  If not, or if it causes any loss of data or work, all you can expect is an "I'm sorry" from me.  BY using the script, you assume all liability for the consequences (good or bad) that arise.

OS X Script to Flush lookupd Cache

| No Comments | No TrackBacks

The lookupd process is a component of Mac OS X which allows programs running on the system to request information about other users and computers on the network.  This process uses an in-memory cache to store information about recent activity.  This cache can become outdated, inaccurate, or incomplete as a result of changes on the network, or through bugs in lookupd.  To correct some kinds of network problems, it is helpful for troubleshooting purposes to clear out or "flush" the lookupd cache.

The script below attempts to flush the lookupd cache, then kill the relevant processes.  Those processes will be automatically restarted by OS X after they're killed.

As with all my scripts, while I've tested this on a number of Mac OS X 10.3.x systems and it appears to work as designed, I provide it "as is" without warranty or support.  If you choose to use it, you assume all responsibility and liability for whatever happens (good or bad).

This script can be run from the command line or a cron task.

OS X Script to Enable/Disable Journaling

| No Comments | No TrackBacks

Journaling is a feature of Mac OS X that is intended to protect the integrity of the files stored on your hard disk drives.  Using this feature can protect against some of the kinds of file corruption that frequently caused crashes, startup problems, etc., in Mac OS 9. 

To learn more about journaling, read the excellent article at:
http://www.larryjordan.biz/articles/lj_journaling.html

The scripts below will turn on (or off) journaling for all connected drives.

While these scripts have been tested by me and appear to work fine on OS X 10.3.x and 10.4, I provide them here without warranty or support, just "as is".  If they work for you and solve a problem for you, great!  If they don't work, cause you to lose data, lose your hair, or anything else, you agree that you assumed all responsibility and liability when you decided to try the script out on your system.

The scripts can be executed from the command line or a cron task.

OS X System Cache Cleaning Script

| No Comments | No TrackBacks

As part of its normal operation, OS X creates a number of cache files that allow it to speed up its operations.  Like any files, these cache files can become corrupted, fragmented, or otherwise damaged.  This can cause the system to slow down, crash, or behave erratically.

To prevent such problems, I developed the following script to delete the system cache files on the computer each night and force a reboot to maintain the system's integrity (since deleting a cache file the OS is using would be "a bad thing").

While I've tested this script on Mac OS X 10.3.x and 10.4 and believe that it functions as designed, I can't promise that it will work on earlier or later OS X releases and provide no warranty or support.  As with all my scripts, this one is provided "as is".  If you are able to make use of it and derive value from it, great!  If not, you assume all responsibility and liability for what happens to your system if you choose to use or modify this script.

This script can be executed from the command line or via a cron task.

OS X Local Cache Cleaning Script

| No Comments | No TrackBacks

As you use your Macintosh, OS X creates a number of cache files in your home directory under "/Users".  These cache files are intended to speed up or otherwise improve system performance.  However, like any files, they can become damaged or corrupted.  When this happens, the system will behave erratically and perhaps crash or lock up.

The script below will automatically delete all the cache files for all the users on the system and attempt to force the system to reboot (so that the now-missing cache files don't cause a crash).

While I've tested this script on several OS X 10.3.x and 10.4 systems and have not suffered any problems as a result of using it, I provide it "as is" and without any warranty of any kind.  If you use it and it works well for you, great!  If it doesn't work or it causes you any kind of problem or loss, you agree that you assumed that responsibility and liability when you tried to use the script.

This script can be run from the command line or as a cron task.

OS X Font Cache Cleaning Script

| No Comments | No TrackBacks

As part of its normal operation, Mac OS X creates "font cache" files that help it to speed up the display of fonts on the screen.  Unfortunately, as with many types of cache files, OS X font cache files can become corrupted or damaged.  When this happens, strange font display problems, application crashes, or system crashes may occur.  It's a good idea to periodically delete the font cache files, which OS X will dutifully rebuild on the next reboot with clean non-corrupted copies.

Font cache files are stored in "/System/Library/Caches" in a variety of files with different names.  Those names all follow specific patterns, so we can easily build a script to look for files with those names and delete them automatically.

This script has been tested and to the best of my knowledge appears to work on OS X 10.3.x and 10.4.  It may or may not work with earlier or later versions of OS X.  As with all my scripts, I provide it "as is" without warranty or support of any kind.  If you choose to try this script, you accept all responsibility for any damage it does to your computer or data.

This script can be executed from the command line or a cron task.

OS X Script to Set Spindown Time for a Disk

| No Comments | No TrackBacks

A power-saving and disk-life-saving aspect of modern operating systems is the ability to shutdown the hard disk drive when it is not in use.  This activity, called "spindown" occurs automatically any time the operating system determines that the hard disk drive hasn't been accessed in a while.

Normally, this is a good thing.  It reduces wear and tear on disk drives, lowers system temperatures (because spinning drives generate heat), and saves electric power.  But there are times when spindown can be a problem.  For example, if spindown is set to a very short value (like one minute), the drive may spin down more often than it should.  As a result, you might find normal activities on the Mac being much slower than you expect.  Paging through a Microsoft Word document as you read it, for instance, might take an unusually long time because the computer has to spin up the hard drive before it can read and display the next page.

The script below adjusts the spindown time for a disk.  If you enter "0" for spindown time, you disable spindown and the disk drive will always run.  This might be OK for a server that's running constantly and needs to respond quickly to requests at all hours, but is probably overkill for a desktop Mac, and would likely drain the battery of a Mac laptop very, very quickly.  A value larger than "0" will specify the number of minutes of disk inactivity the computer should wait before spinning down the hard disk drive.  For example, entering "csh setspindown 30" would cause the computer to wait for 30 minutes of inactivity before spinning down the hard disk drives.

To use this script, copy and paste the lines below into TextEdit.  Save the file as "setspindown" onto your Mac's hard drive.  Go to a Terminal window and navigate to the location of the file.  Enter "chmod a+x setspindown" to make the script executable.  When you want to use it, type "csh setspindown xx" where "xx" is the number of minutes you want the computer to wait before spinning down the hard disk drive.  If the computer prompts you for a password when you execute the script, the password it needs is that of an administrator.  If you don't have administrator permissions, you probably can't run this script.

This script has been tested in MacOS X 10.3.x and 10.4, and appears to work as designed.  No warranty of any kind is made by me that this script will work on your system, though I see no reason why it wouldn't.

OS X Internet Cache Cleaning Script

| No Comments | No TrackBacks

As you use your Macintosh to browse the web, your web browser begins storing "cache" files on your computer's hard disk drive in order to make browsing faster.  For example, if you were looking at Ford's web site, trying to decide what new car to buy, your browser might cache a copy of the Ford logo on your Mac.  Each time you look at a new page, instead of asking Ford's web server for another copy of the Ford logo, your Mac uses the file in its cache (which it can read much faster than it can get a new copy from Ford's server).  This is generally a good thing.

But like any other cache files, these Internet cache files can become corrupted.  When this happens, the web browser may crash, behave strangely, or even refuse to run at all.  In an attempt to prevent this problem, I took some time to try to determine where the different Mac web browsers we use store their cache files.  Then I wrote the script below to automatically clear out those caches each night.

As with all my scripts, this one was tested with OS X 10.3.x and 10.4 and the web browsers and versions we use at my place of employment.  While I believe that this script works as intended and that it won't wipe out your hard drive or cause you some other problem, I can't warranty that.  If you choose to use this script on your Macintosh, you assume all liability and responsibility for what happens to your computer as a result.  If the script works for you, great!  If not, I'm sorry and I hope you didn't lose anything important - but there's nothing I can do for you.

This script can be executed from the command line or a cron task.