2

I am trying to create a bash script that automates all parts of a .dmg/pkg software install.

For example, the script should pull the installer from here: http://download.techsmith.com/snagitmac/enu/Snagit.dmg

It should pull the installer from online, run the installer, automatically proceed past all the user prompts, and run root so the user should just have to run the script.

Is there anyway to make the snag it installer proceed without human interaction and finish the installer via this script?

This is the script I have so far:

#!/bin/bash -e

cd ~/Desktop
curl -O http://download.techsmith.com/snagitmac/enu/Snagit.dmg
  • Yes, I am trying to develop a script that other users will use on their own computer. – MacMania Jul 18 '16 at 6:24
  • I see what you're saying. I just tried in a private window. I have to find a way to get a direct download link that anyone can use. – MacMania Jul 18 '16 at 6:29
  • What exactly is your question here? How to get a direct download link (which would be off-topic here), how to access a .dmg file from bash or something completely different? A Q&A site like AD doesn't work very well to help you develop a script in a back-and-forth fashion, please ask specific questions instead (like maybe "how can I access the content of a .dmg file from bash", "how do I run an installer from a .dmg file" etc.). Please also show what you have tried so far (including searching this site) to avoid getting answers which won't work. – nohillside Jul 18 '16 at 6:38
  • Thanks, all. Your information helped me learn a lot, and I have updated the question with the appropriate link. My question now is, is there anyway to make the snag it installer proceed without human interaction and finish the installer via this script? – MacMania Jul 18 '16 at 7:25
  • 1
    did you try using homebrew cask? – Sarge Borsch Jul 18 '16 at 11:43
1

The following should work for Snagit (and, with adaptions, for any application which is delivered in a .dmg and must be dragged to /Applications manually). It will not work for package installers.

#!/bin/bash

cd ~/Desktop

# get image from site
curl -O http://download.techsmith.com/snagitmac/enu/Snagit.dmg

# mount image
hdiutil attach Snagit.dmg

# copy app, remove old version first if installed
if [[ -d /Applications/Snagit.app ]]; then
    sudo rm -rf /Applications/Snagit.app
fi
sudo cp -r /Volumes/Snagit/Snagit.app /Applications/Snagit.app

# unmount and remove image
hdiutil detach /Volumes/Snagit
mv Snagit.dmg ~/.Trash/

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .