Shell script to install many PKG

Pete used Ask the Experts™
How can I script:

Install all PKG in /foldername

Maybe write log somewhere too....

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You use the installer command to install a package.  /var/log/install.log is where all package installs logs are sent to.

installer -tgt / -pkg packagename.pkg

man installer to get the manual page.

I don't believe you can't change the install destination on the drive without modifying the package.  You can only change the installation disk.
If you want to manually extract the package, you'll have to use plutil to extract it into a folder to examine the contents.  It does not install a package.
plutil --expand /path/to/package.pkg /destination/directory


Ok thanks but but I need some kind of command

For each pkg in the folder, install the pkg.
for package  in /path/to/*.pkg ; do installer -tgt / -pkg $package; done

Open in new window


Thanks, that makes sense. Would I need to think about /tgt, I just want them to install to their default  location..?
The target is the disk volume, not a folder.  You can't specify a folder, only a disk volume.  Specifying -tgt / basically tells it to install it on the boot volume in the default location.

If you had a 2nd disk mounted on /Volumes/Untitled/ then you could specify -tgt /Volumes/Untitled/ and it would install it on the 2nd disk, in the corresponding "default" location on that disk.  If there's no disk volume mounted there, the command will fail with an error.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial