Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to silently install dmg file in mac os x system (using shell script)?

I have used the following command for dmg file attach and detech

hdiutil attach installer.dmg 
hdiutil detach installer.dmg 

in the dmg file it contains test.app GUI mode installation, i can drag the test.app to application location

What i need is when i double-click the script, dmg containing the app should install automatically to

application location in mac os x after that terminal window should automatically closed

Thanks in advance for your answers

like image 347
user3214224 Avatar asked Sep 11 '25 22:09

user3214224


1 Answers

well, a shell script like the following should do the job:

install_app.sh

#/bin/sh

VOLUME=`hdiutil attach $1 | grep Volumes | awk '{print $3}'`
cp -rf $VOLUME/*.app /Applications
hdiutil detach $VOLUME

and you can run it that way:

% install_app.sh ~/Downloads/MyApp.dmg

be aware that I'm doing no argument checking in that little script, and that any existing app with the same name will get overwritten.

HTH

like image 179
zmo Avatar answered Sep 13 '25 10:09

zmo