I am trying to install an application through command line in OS X. This is what I am trying:

hdiutil attach app.dmg
cd /Volumes/appvolume
installer -pkg app.pkg -target "/"

This works fine, however, I am not able to get an output from the installer command from which I can capture the amount of progress made and the time/amount remaining. I tried the verbose option

installer -verbose -pkg app.pkg -target "/"

But this only prints output like installer: Optimizing system for installed software…....., etc, nothing about progress. But it surely knows about progress, because when I install the app via double clicking, the installer window that pops up shows a deterministic progress bar that progresses gradually and reaches full length when installation is complete.

Any way I can capture the progress status through command line installer as well?


You were close - the option you're looking for is -verboseR:

Usage: installer [-help] [-dominfo] [-volinfo] [-pkginfo] [-allowUntrusted] [-dumplog]
             [-verbose | -verboseR] [-vers] [-config] [-plist]
             [-file <pathToFile>] [-lang <ISOLanguageCode>] [-listiso]
             [-showChoicesXML] [-applyChoiceChangesXML <pathToFile>]
             [-showChoicesAfterApplyingChangesXML <pathtoFile>]
             -pkg <pathToPackage>
             -target <[DomainKey|MountPoint]

Here's installer's output installing a Firefox 43.0.1 .pkg built with AutoPkgr with that flag:

timmay:~ da4$ sudo installer -pkg /Users/da4/Desktop/auto/Firefox-43.0.1.pkg -target / -verboseR
installer: Package name is Firefox-43.0.1
installer: Upgrading at base path /
installer:PHASE:Preparing for installation…
installer:PHASE:Preparing the disk…
installer:PHASE:Preparing Firefox-43.0.1…
installer:PHASE:Waiting for other installations to complete…
installer:PHASE:Configuring the installation…
installer:PHASE:Writing files…
installer:PHASE:Writing files…
installer:PHASE:Optimizing system for installed software…
installer:PHASE:Validating packages…
installer:PHASE:Validating packages…
installer:PHASE:Finishing the Installation…
installer:PHASE:The software was successfully installed.
installer: The upgrade was successful.
timmay:~ da4$

I'm not exactly sure when the -verboseR option was added to OS X's installer, but it's present in 10.9+.

  • Thanks. While we are at it, can you suggest a way for me to capture the output number whenever the percentage is shown? Say whenever the line installer:%9.883908 comes along, I want to capture the 9 part and echo it instantly (and suppressing the original output supposed to be given by verboseR). Probably I need to use grep, I cannot figure out how. That is, the output of my command will be 9, then 30, then 51, etc.. – SexyBeast Dec 20 '15 at 19:23
  • If you wanted to grab the entire percentage, you could use sed: grep % | sed 's/installer:%//g - if you wanted to only capture to whole integer, you'd probably have better luck with awk – da4 Dec 20 '15 at 19:35
  • Problem is the Mac does not come with GNU sed, so I cannot rely on sed. OSX's version of sed is clumsy.. – SexyBeast Dec 20 '15 at 19:36
  • How so? timmay:~ da4$ sudo installer -pkg /Users/da4/Desktop/auto/Firefox-43.0.1.pkg -target / -verboseR | grep % | sed 's/installer:%//g' 7.573892 28.364039 46.844170 95.628934 97.262500 97.750000 100.000000 – da4 Dec 20 '15 at 19:38
  • Lemme try it out then.. – SexyBeast Dec 20 '15 at 19:41

Sending ^ + T to a running process in Terminal will request the 'status' of that process. This is a hold-over from early BSD and is cross-compatible with most shells (bash, csh, etc.).

A more in-depth conversation with an eye towards Apple specifically can be found here.

  • Sorry I did not understand you. How can I "send" ^+T to a command in a shell script? – SexyBeast Dec 20 '15 at 18:57
  • With redirection. You'll want to look here and here to get started. – agentroadkill Dec 20 '15 at 19:08
  • Addendum: I may have misunderstood. If you're sitting looking at a terminal waiting for something to happen, type control and T (together) on the keyboard to get its status. – agentroadkill Dec 20 '15 at 19:09
  • That was very interesting. But not applicable in my problem.. – SexyBeast Dec 20 '15 at 19:25

You must log in to answer this question.

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