If you ever need to use a script to remotely copy, mount a dmg and then run a package, here is how to do it
Installing packages from the command line – Mac OS X Hints

I sometimes need to install updates remotely on a server I maintain. I already knew about the command line version of softwareupdate, but I was looking for a way to install packages (.pkg) that were already located on the remote box. I finally found the installer command. To install a package, type:

 sudo installer -pkg Desktop/Java1.4.1.pkg -target /

In most cases, -target will be the root of your boot volume (/), but you may also specify /Volumes/OtherDrive. Also note that the installer will not prompt you if the update requires a restart. If you know that it requires a restart, type sudo reboot after confirmation of successful install.

Mount a DMG from the Command Line in Mac OS X

From the command line use the following syntax to mount the image:
hdiutil attach /path/to/diskimage.dmg

Mount a DMG from the Command Line in Mac OS X

Recalling that the device name of the mounted image, use the following syntax to unmount the dmg:
hdiutil detach /dev/disk1s2
If you missed the device location earlier, you can retrieve information on all mounted drives and images by using:
hdiutil info

I’m Rich & Co.

Welcome to Tongfamily, our cozy corner of the internet dedicated to all things technology and interesting. Here, we invite you to join us on a journey of tips, tricks, and traps. Let’s get geeky!

Let’s connect