Shell script to install many PKG

How can I script:

Install all PKG in /foldername

Maybe write log somewhere too....

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
PeteAuthor Commented:
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

PeteAuthor Commented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.