sorin
sorin

Reputation: 170856

How do I install a DMG file from the command line?

I am looking for small bash or python script that will install a .dmg file.

We'll assume that the dmg contains one or more .app directories that have to be copied to /Applications, overriding any already existing directories.

Files or directories not matching the *.app pattern are to be ignored.

Upvotes: 8

Views: 16705

Answers (1)

nimrodm
nimrodm

Reputation: 23849

You can mount the disk image using

hdiutil attach -mountpoint <path-to-desired-mountpoint> <filename.dmg>

The disk image will be mounted at the selected path (the argument following -mountpoint). Then, search for an .app file and copy the file to /Applications.

Once you have finished installation unmount the disk image:

hdiutil detach <path-to-mountpoint>

Upvotes: 14

Related Questions