1

I'm trying to write a simple shell script for OS X 10.10, to install a list of applications for new Macs we're getting in. I just want to fire off each installer one at a time to install each application. I'm using a bash script, which works fine, except for some installs I'm just calling the GUI installer and installing that way clicking Next, Next Next... because that particular app didn't install properly through the terminal. (which is fine)

My problem is, that when the script opens the GUI installer for App A, it will then keep running down the script opening the commands next in line. What I want is for the script to wait to run the next command for as long as that installer window is open for. Windows DOS works this way, where you can make a batch file and it won't execute the next line until the first install is completed. So I'm looking for similar behavior.

I've tried a couple of things from reading but none of them have worked. As you can see, the places where I've put the "wait" command is where I want to to wait for the GUI installer to finish.

#!/bin/bash

# Install Script for OS X BYOD Laptops

# Installing Office 2016

open /Volumes/USB30FD/packages/Microsoft_Office_2016_Volume_Installer.pkg
wait
# sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/Microsoft_Office_2016_Volume_Installer.pkg -target /
sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/Microsoft_AutoUpdate_3.2.0_Updater.pkg -target /
sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/Microsoft_Excel_15.15.0_Updater.pkg -target /
sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/Microsoft_OneNote_15.15.1_Updater.pkg -target /
sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/Microsoft_Outlook_15.15.0_Updater.pkg -target /
sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/Microsoft_PowerPoint_15.15.0_Updater.pkg -target /
sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/Microsoft_Word_15.15.0_Updater.pkg -target /

defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Word.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Excel.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft PowerPoint.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'
defaults write com.apple.dock persistent-apps -array-add '<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>/Applications/Microsoft Outlook.app</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>'

killall -HUP Dock


# Install ShareFile\

sudo cp -r /Volumes/USB30FD/apps/ShareFile.app /Applications/
wait
open -a /Applications/ShareFile.app
wait

# Install Absolute Computrace

# sudo installer -verboseR  -pkg /Volumes/USB30FD/packages/RPClient.pkg -target /
open /Volumes/USB30FD/packages/RPClient.pkg
wait
open /Volumes/USB30FD/Ctclient103319-304806/ctmweb.app

# Install Symantec Endpoint Protection

# Run the GUI installer instead:  open /Volumes/USB30FD/apps/Additional\ Resources/SEP.mpkg
sudo installer -verboseR  -pkg /Volumes/USB30FD/apps/Additional\ Resources/SEP.mpkg -target /
wait
/Library/Application\ Support/Symantec/LiveUpdate/LUTool


# Install Trend Disk Encryption

open /Volumes/USB30FD/packages/Trend\ Micro\ Full\ Disk\ Encryption.pkg

I'm pretty novice when it comes to shell scripts, so the simpler the better. Thanks!

  • So, I just realized I could use a pause statement which will get me almost the same functionality. read -p "Hit Enter for the next step..." Thanks – Fish Nov 5 '15 at 23:09
2

The Mac OS X open has a -W or --wait-apps option that might be relevant:

% open -h
...
      -W, --wait-apps   Blocks until the used applications are
                        closed (even if they were already running).

Not sure what OS version they added that at, though.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.