Datareign

Here are some things we've found useful in real life running.

Show Text instead of Graphics During Boot

Simply hold down COMMAND-V from when the chime sounds until the log starts to appear.

Setting default applications

Default application to open a particular file

Select the file in a Finder window, Ctrl-Click to get the pop-up menu, click on the arrow next to 'Open With:' to show the dialogue, select the application to use from the selection box (you can use the 'other' item right at the bottom to hunt for an application that isn't on the menu).

Defult Application for all files

Do Get Info (Command-I) and expand the Open With tree. Select the file you want to be the default application, then click the Change All button.

Default Internet Applications

In 10.2 or earlier, open System Preferences from the Apple menu, select 'Internet' and follow the dialogue there.

For 10.3 onwards, it's a little trickier. To change the default web browser: start Safari, select 'Preferences' under the 'Safari' menu, select the 'General' tab (the leftmost item) and pull down the 'Default Web Browser' selection box. If the browser you want to use is not offered, choos the 'Select…' item and use the file dialogue to find your browser.

The procedure for choosing a mail client is broadly similar but use Mail instead.

Update Traps

If an update fails and you need to re-install packages, be aware that many installers will fail to re-install unless you delete the package first. This is because many Apple installation packages check the date of any existing files and simply leave them in place if the target machine's files are dated later than the installation files.

As an example, the OS-X update to 10.3.9 broke my Java installation so that running Java gave a 'segmentation fault'. When I found the Java installation kit and installed it, the installation appeared to work but the fault remained.

Checking the dates on the files in the directory that holds the main Java executable (/System/Library/Frameworks/JavaVM.framework/Commands) quickly revealed what was going on…

 
 -rwxr-xr-x 1 root wheel 61236 16 Apr 22:28 appletviewer
 -rwxr-xr-x 1 root wheel 61236 16 Apr 22:28 extcheck
 -rwxr-xr-x 1 root wheel 61236 16 Apr 22:28 idlj
 :
 :
 -rwxr-xr-x 1 root wheel 61236 16 Apr 22:28 tnameserv

The time-stamp on the files was the date of the update. Deleting the Java Framework directories (rm -d /System/Library/Frameworks/Java*/*) and re-running the installation routine fixed the problem.

This problem can be assumed to apply to any installation that relies on existing files having a date earlier than its own. If you have to re-install after a failed update this will, almost certainly, not be the case, so beware!

Keyboard Shortcuts

  • Control+F2 This one's truly useful - from 10.5.5 it sets the Menu Bar active, highlighting the Apple Menu. Press the down arrow key to open the menu, then any arrow key to navigate. A life-saver if your mouse is acting up!
  • Control+F4 Another goody, this one steps through each open window on the desktop (as opposed to Command-Tab which steps through each currently open application but only brings up the frontmost window belonging to each application). Note that, if you're using Spaces, the current desktop is the one you're looking at.
  • Command+Shift+3 Takes a shot of the entire screen and stores it in the clipboard.
  • Command+Shift+4 Changes the mouse cursor to a selection tool so that you can define the area to copy. Click and hold the mouse to define the area. When you release the mouse, the image is copied to the clipboard.
  • Command+Shift+4+Spacebar The mouse cursor changes to a nifty little camera. Whatever window you hover the mouse over becomes the target. Click the mouse to copy the image of the window to the clipboard.

CD Problems

Can't See CD in Finder

Check under System Preferences|CDs and DVDs|When you insert a blank CD. This needs to be set to Open Finder to make the disk mount on the desktop.

Printer Problems

Can't print to a shared printer?

Symptoms: You can see a printer shared from another computer in the printer setup and you successfully select it. When you try to print to the shared printer, all seems well but nothing happens. Opening the print manager presents you with the message:

  "unable to lookup host <name of computer sharing the printer> unknown host"

The problem is almost certainly your hosts file. To fix it you need to use Terminal and log in as 'root' (you have set up a root password, haven't you?)

Once logged in, change to the /etc directory (cd /etc) and then edit the file 'hosts', which may look something like…

 ##
 # Host Database
 #
 # localhost is used to configure the loopback interface
 # when the system is booting.  Do not change this entry.
 ##
 127.0.0.1       localhost
 255.255.255.255 broadcasthost
 ::1             localhost 
 fe80::1%lo0     localhost

You need to add a line with the address of the host computer, a tab (spaces will not do) and the name of the host, exactly as it appears in the 'Unable to lookup host' message, e.g:

  192.168.0.45   Print-Server-G5.local

Then save the file and try your printer - it should now work.

Important: you will need to have fixed IP addresses on your network for this to work because, if you use DHCP, the printer host's IP address may well change when it is switched on again.

Using Applescript to Start a Unix Application

You sometimes want a Unix application to run automatically when the computer starts up. An example is the excellent open source application Synergy which allows you to control several computers from a single console via a network. Whether the Mac is the master machine or a slave, you'll want Synergy active as soon as the machine is switched on.

Synergy isn't a GUI application but runs from the Unix command line. The default method of starting it is to open a terminal window and type in the command to start it…

 synergys -c synergy.conf

Now you could put this command into a shell script and add it to the start up files but on a Mac this isn't all that neat. There is, however a better way and that's to use Applescript.

OS-X comes with Applescript installed and all you need to do is look for the Script Editor application which lives in Applications | Applescript on your startup disk. This is not only an editor but a controller for the Applescript compiler, so everything's in one place.

The command we need to run a Unix programme is do shell script and here's the complete command to run Synergy as a server…

 do shell script "/Applications/Synergy-1.2.2/synergys -c /Applications/Synergy-1.2.2/synergy.conf

where synergy.conf is the configuration file defining the relationships between your computers.

It's simple enough, isn't it? The only thing you need to note is that you MUST give the complete path for the command and any arguments unless all your paths are already set up for the root user. Even if they are, full paths are probably a good idea for future maintainability.

You'll want to save the script and then you'll want to convert it to an application. Having saved the script in the default (script) mode, which will crate a file with the extension .scpt, do save as. This will invoke a file save dialog box. You will need to pull down the File Format list and select Application to build a runable programme. Then you can save the file in a location to suit yourself.

The last part of the job is to add this script to the list of items to be started when you log on to your computer. (Even if you're the sole registered user, OS-X still goes through a log-in process when it starts up.)

The way to do this, is to invoke System Preferences | System | Accounts | Startup Items. This will bring up the preferences pane and you need to click the '+' under the list ”These items will start automatically when you log in”. You can then add your command to the list.

Close System preferences and the job is done. From now on, whenever you start up, Synergy will start up automatically. You can use this technique to run any Unix command but be aware that many commands will already be running, such as the Apache web server which forms the basis of Apple's 'Personal Web Server'.

Last modified: 2010/06/27 11:34