Mount and install OS X packages from the command line
If you need to install a .pkg application wrapped in a .dmg file from the command line (say, if you only have SSH access to the machine) there are a few command line utilities that will let you do this. For instance, let's say you're trying to install DarwinPorts on a remote OS X box.cd ~/Desktop curl -O http://darwinports.opendarwin.org/downloads/DarwinPorts-1.2-10.4.dmg hdiutil attach DarwinPorts-1.2-10.4.dmg cd /Volumes/DarwinPorts-1.2/ sudo installer -pkg DarwinPorts-1.2.pkg -target "/" hditutil detach /Volumes/DarwinPorts-1.2/
In a nutshell, this 1) goes to your Desktop folder 2) grabs DarwinPorts from the opendarwin site 3) mounts the dmg 4) goes to the newly mounted DarwinPorts volume 5) installs the package, targeted to the root, as the root user 6) ejects the mounted disc image.