Posts RSS Comments RSS 48 Posts and 155 Comments till now

Automator workflow to import images into PowerPoint

I have lots of users where I work that have folders full of pictures that they just want to import into PowerPoint. I came up with this Automator workflow to allow just that.

It makes a new PowerPoint presentation, then lets you select the folder that contains the images you want to import. It then pads the images so that they fit onto a standard PowerPoint slide and imports them.

This workflow uses actions from the Microsoft Automator Actions package.

Click on PowerPoint AutoImport Workflow to download

Get the system version using Terminal

There is a nice utility available from the command line that allows you get some basic system information quickly. All of this information is available in other places but there are times when it’s easier to get it at the command line.

Open up Terminal and type “sw_vers” (no quotes) and hit return. The results you’ll get look like this:


ProductName: Mac OS X
ProductVersion: 10.4.9
BuildVersion: 8P135

You can use different variations such as “sw_vers -productVersion” to get just that information. On the same machine in the first example that would return:


10.4.9

I recently had a need to get this information at the command line for an installer I was building. I only needed to know the first part of the product version (10.3, 10.4, etc.) so I put together a short shell script to grab that information for me.


#!/bin/bash

sysver=`sw_vers -productVersion | cut -c 1-4`
echo $sysver

if [ $sysver = 10.4 ]; then
echo "This is a Tiger System"
elif [ $sysver = 10.3 ]; then
echo "This is a Panther System"
else
echo "This system is too old"
fi

This script was just a “proof of concept” on for me. Once I knew it worked I could control what things happened depending on if the machine was running 10.4, 10.3 or an older version. Just substitute the “echo” statements for what should happen. If you want to try this out paste the script into a plain text document and save it with a “.sh” extension. Go into Terminal and make it executable with chmod.

Setting the startup disk using Terminal

While it’s quite easy to change which disk your machine starts up from using System Preferences there may be times when you need/want to do it either at the command line or within a script.

The command for setting the startup disk using Terminal is “bless“. To get the full story on “bless” open up Terminal and type “man bless” (no quotes).

To change the startup disk type the following in Terminal:

sudo bless -mount /Volumes/"name of your startup disk" -setBoot

So, if the desired disk was named “TestDisk” you would type this:

sudo bless -mount /Volumes/TestDisk -setBoot

If your disk name has spaces in it you’ll need to put quotes around the path to the disk, like this:

sudo bless -mount "/Volumes/My Disk" -setBoot

You can incorporate this into a UNIX shell script to reboot your machine to another disk at a certain time. Perhaps you want to reboot to another disk every Friday to run a disk utility on it, or to image it.


#!/bin/bash
bless -mount /Volumes/TestDisk -setBoot
shutdown -r now

Breaking down this script the first line sets the disk your Mac will boot from. The second line tells it to shutdown and restart immediately. If you have an Intel Mac you can add “–nextonly” at the end of the “bless” line. That will boot the machine to that volume first and then boot back to the original volume on subsequent reboots without having to reset the startup disk.

This command also comes in handy if you’re booting back and forth between volumes to test things. For example, you have a partition with 10.3 and another with 10.4 on it and you want to test some software in 10.3. You can wrap all of this up in an AppleScript and either save it on your desktop as an application or save it as a script and put it in your Script menu.

Paste this code in Script Editor and run it. Make sure you change the disk name to your disk. What for the AppleScript line breaks in the code. Any line that ends in “¬” means the line below is part of the same line. Pasting it in as it is on the web page will still work however.

[codesyntax lang=”applescript” lines=”no”]
do shell script “bless -mount \”/Volumes/Drive Name\” ¬
-setBoot with administrator privileges
do shell script “shutdown -r now” with administrator privileges
[/codesyntax]

Then simply click on the application or select if from the Script menu, enter your admin name and password and it will select the disk and reboot for you.

If you want to choose between several disks you can add in a dialog box to let you choose the correct disk.

[codesyntax lang=”applescript” lines=”no”]
display dialog “Select a startup disk” buttons ¬
{“name of disc 1”, “name of disc 2”]
set bootVol to the button returned of the result as text
do shell script “bless -mount \”/Volumes/” ¬
& bootVol & “\” -setBoot” with administrator privileges
do shell script “shutdown -r now” with administrator privileges
[/codesyntax]

Fixing Files with broken Resource Forks

This is less and less an issue but it still occasionally happens. Someone sends you a file, usually an application, that has resource forks in it. Either through the email system they used or the method the transferred to a server with the resource fork gets stripped out. Usually you’ll see it as a file with the same name as the application with a “.” in front of it.

You can recombine these into something useful with a somewhat hidden application on your Mac. It’s called, appropriately enough, “FixUpResourceForks”. It has to be run out of Terminal but it’s quite simple.

  • Open Terminal
  • Make sure both files reside in the same folder.
  • Enter the following in Terminal on one line:
    /System/Library/CoreServices/FixupResourceForks /path/to/folder

Obviously “/path/to/folder” is the path to the folder that holds both files. The easy way to find that is to type the first part of the command in Terminal followed by a space. Then drag the folder containing the files onto the Terminal window and it will automatically put in the correct path. Then just hit “Return” and it will recombine the files into one usable file again.

Identifying a DHCP server

Here are three quick ways to identify which DHCP server your machine is getting it’s IP address from. This can come in handy when trying to track down rogue DHCP servers that pop up on a network.

In Tiger:

  • Open System Profiler
  • Click on “Network”
  • Select which service you want to see
  • It is listed under “DHCP Server Responses:” next to “Server Identifier”

In Panther and below:

  • In Terminal type “ipconfig getoption en0 server_identifier”
  • Change “en0” to “en1″ if using wireless

You can also wrap it in an AppleScript. This should work on most version of OS X.

[codesyntax lang=”applescript” lines=”no”]
do shell script “ipconfig getoption en0 server_identifier”
set theIP to the result
display dialog “Your DHCP server IP is: ” & theIP
[/codesyntax]

Save it as an application. Great for getting this information from the Terminal-challenged user.

RotundaCam widget

I wrote this widget to display the RotundaCam at the University of Virginia. Download it, unzip it and double click to install it.

RotundaCam icon
The RotundaCam widget

Clearing the MCX cache

When you manage the preferences on your workstations via Workgroup Manager the settings are stored on the local clients in the MCX cache. This can be manually cleaned out in NetInfo but there is a much easier way.

  • Open Terminal
  • Run the following command. Use “sudo” if you’re not logged in as root:
    /System/Library/CoreServices/mcxd.app/Contents/Resources/MCXCacher
  • Enter your admin password

The command needs to be run on each machine seperately.

If you are using Apple Remote Desktop 3.x you can enter this withou the “sudo” in the “Run UNIX” box and run it as root on a large number of machines at once..

Get the name of the computer in Tiger (10.4)

In certain AppleScripts you’ll find you need to get the name of the computer you’re currently on. Usually you need this for things like writing to logs, etc. Here’s how to do it in Tiger:

[codesyntax lang=”applescript” lines=”no”]set theName to the computer name of the (system info)[/codesyntax]

This sets the variable “theName” to the name of your computer from the Sharing preference panel

Here’s an example. Paste the text below in Script Editor and run it.

[codesyntax lang=”applescript” lines=”no”]set theName to the computer name of the (system info)
display dialog “My computer’s name is ” & theName[/codesyntax]

« Previous Page