How To Determine Dynamic Library Dependencies For An Executable or Library File in OS X

This script uses otool -L to determine and print all dynamic library dependencies of a given executable or library file recursively and you use it like this:

$ checklibs.pl /bin/ls
   /bin/ls:
            /usr/lib/libgcc_s.1.dylib
            /usr/lib/libncurses.5.4.dylib
            /usr/lib/libSystem.B.dylib
   /usr/lib/libgcc_s.1.dylib:
            /usr/lib/libSystem.B.dylib
   /usr/lib/libncurses.5.4.dylib:
            /usr/lib/libgcc_s.1.dylib
            /usr/lib/libSystem.B.dylib
   /usr/lib/libSystem.B.dylib:
            /usr/lib/system/libmathCommon.A.dylib

Here’s the script which was written by Marc Liyanage:

#!/usr/bin/perl
#
# Written by Marc Liyanage <http://www.entropy.ch>
# use strict;
use warnings; 

my ($file) = @ARGV;
die $! unless (-f $file); 

my $libs = {};
check_libs(file => $file, libs => $libs); 

print
	map {("\n$_:\n", map {"\t$_\n"} sort {lc($a) cmp lc($b)} @{$libs->{$_}})}
	sort {lc($a) cmp lc($b)}
	grep {@{$libs->{$_}}}
	keys(%$libs);
sub check_libs {
	my (%args) = @_;
	my $libs = $args{libs};
	my @file_libs = grep {$_ ne $args{file}} grep {$_} map {/^\s+(\S+)/} qx(otool -L $args{file});
	$libs->{$args{file}} = \@file_libs;
	foreach my $lib (grep {!$libs->{$_}} @file_libs) {
		unless (-f $lib) {
			$libs->{$lib} = ['(missing)'];
			next;
		}
		check_libs(%args, file => $lib);
	}
}

In case my blog software mangles the code above, you can download the script in a plain text file by clicking here: checklibs.zip

Code

How to Determine What Program Is Listening on a Port in OS X or Linux

To determine what daemon or program is listening on a port in Linux or OS X you can use the lsof command. You need to run the command while logged in as root or if your operating system supports sudo like OS X, you can use that.

Command to run in Linux:

lsof -i -nP

Command to run in OS X:

sudo lsof -i -nP

Terminal

How to Extract the Windows Driver CD From Boot Camp Assistant

Burn the DMG image file located in the “Resources” folder which is inside the Boot Camp Package. The Boot Camp package is in the utilities folder and is what you click on to run Boot Camp Assistant.

  1. Right-click over the Boot Camp Assistant app in the Utilities folder.
  2. Select “Show Package Contents”
  3. Open the Contents folder and then the Resources folder
  4. Burn the DMG image file in that folder. The DMG image file will probably be named DiskImage.dmg

NOTE: These procedures are for Boot Camp beta running in Mac OS X Tiger 10.4. In Mac OS X 10.5 Leopard you can just use the Leopard install CD/DVD as the Windows driver CD.

iMac XP

10.5 Leopard – Change the Version of Apache that Starts Up

A clean install of MacOS X 10.5 Leopard will result in Apache 2 being the default version of Apache that starts up when you enable the web service. If you performed an upgrade to Leopard from a Tiger install then Apache version 1.3 will be the default version of Apache that starts up. MacOS X 10.5 Leopard comes with both versions of Apache. If you need to change the version of Apache that starts up do the following:

  1. Stop the web service if it is running.
  2. Edit the hidden file /var/db/.ApacheVersion with pico or some other text editor
    1. 1 for apache 1.x, 2 for apache 2.x
  3. Restart the web service
  4. The Server Admin app will now display the correct settings for whatever version of Apache you are running
  5. Done.