Archive

Posts Tagged ‘script’

Selective Automatic OS X Software Updates

July 27th, 2005

Back when I began doing OS X
administration, I asked myself how I could automatically keep the OS X
systems updated without having to login to them remotely each day to run
Software Update and without giving end users administrator access to the
machines (which is a no-no in our corporate security policy). I found
out that Apple makes it pretty easy to do this with the command line,
which means it can be setup to run in a cron job.

For instance, to automatically get all the latest required
updates from Apple installed on a machine without having to do it
manually, you can create a cron task to issue the following command as
root:

softwareupdate -q -i
-r

This works fine for most
users, most of the time. Unfortunately, what if you’re a QuickTime Pro
user and Apple puts out a QuickTime update marked as
“required”? That’s right, Software Update will dutifully
download the new version and install it over top of the version you’re
registered for. Unless you have the time and money to call them and buy
a new registration code for the new version of QuickTime, your
“Pro” features are all locked down again.

This is precisely the situation Apple placed me in as an
administrator a while ago. One of our artists’ machines was
automatically updated to Quicktime 7.0 from 6.5.2 Pro, rendering the
“Pro” functionality inactive. Because of the way things work
in our corporate environment, it’s not a quick or simple process for him
to just buy the new registration code. It means a lengthy purchase
process that can take weeks, sometimes even months. An artist can’t do
without QuickTime for that long. But as the Mac Administrator, I
couldn’t do without the systems getting their security updates for that
long. Apple had once again put me in a bind.

Read more…

admin Mac Support , , , , , , , , , , , , , , , ,

VBScript Function to Determine if a Registry Entry Exists

June 15th, 2005

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.

Read more…

admin VB and VBScript , , , , , , , , , , ,

VBScript “Sleep” Function

June 15th, 2005

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. 

Read more…

admin VB and VBScript , , , , , , , ,

VBScript Subroutine to Split Up a Tab-Delimited Line of Text

June 15th, 2005

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.

Read more…

admin VB and VBScript , , , , , , , , , , ,

OS X Script to Create a User from the Command Line

June 15th, 2005

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.

Read more…

admin Mac Support , , , , , , , , , , , , , , , ,

OS X Script to Re-Prebind the System

June 3rd, 2005

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.

Read more…

admin Mac Support , , , , , , , , , , , , , , , , , ,

OS X Script to Repair Permissions on All Volumes

June 3rd, 2005

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.

Read more…

admin Mac Support , , , , , , , , ,

OS X Script to Remove .DS_Store and .localized Files

June 3rd, 2005

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

Read more…

admin Mac Support , , , , , , , , , ,

OS X Script to Flush lookupd Cache

June 3rd, 2005

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.

Read more…

admin Mac Support , , , , , , , , , , , , , ,

OS X Script to Enable/Disable Journaling

June 3rd, 2005

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.

Read more…

admin Mac Support , , , , , , , , , , , , , , ,