Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Installing packages from the command line Install

I sometimes need to install updates remotely on a server I maintain. I already knew about the command line version of softwareupdate, but I was looking for a way to install packages (.pkg) that were already located on the remote box. I finally found the installer command. To install a package, type:

 sudo installer -pkg Desktop/Java1.4.1.pkg -target /
In most cases, -target will be the root of your boot volume (/), but you may also specify /Volumes/OtherDrive. Also note that the installer will not prompt you if the update requires a restart. If you know that it requires a restart, type sudo reboot after confirmation of successful install.

For more info see man installer.
    •    
  • Currently 3.00 / 5
  You rated: 1 / 5 (7 votes cast)
 
[93,801 views]  

Installing packages from the command line | 13 comments | Create New Account
Click here to return to the 'Installing packages from the command line' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
One problem I've found
Authored by: David on Jun 17, '03 11:03:59AM

is that some packages (notably Fink) don't work using this installer application. Kind of frustrating when you need a command-line app on a remote computer and you can't install Fink in order to install the app! :-)

---
www.AcornWebDesigns.com
Quality websites for inexpensive prices (Is that an oxymoron?)



[ Reply to This | # ]
Ditto (not the command ;)
Authored by: sjonke on Jun 17, '03 01:00:08PM

I also discovered this installer command the day that I read the recent article here about installing a no-ip linux client as a startup item. The .pkg that was pointed to by that article did not work via the command line. I had to do it from home. Even then it still didn't seem to be workgin right, though, so I removed it and installed the fink version which seems to be working, once I understood how to set that version up. A fully working command-line installer is much needed, but if it works on some things now that's still pretty good....

---
--- I hate Microsoft and I vote



[ Reply to This | # ]
One problem I've found
Authored by: mbartosh on Jun 17, '03 05:51:57PM
You have to run these packages (OS updates usually fall under this category) from root.

cd /
sudo /usr/sbin/installer -pkg /path/to/pkg.pkg -target /

---
4am Media, Inc. Mac OS X Training and Consulting

[ Reply to This | # ]

sudo reboot
Authored by: vonleigh on Jun 17, '03 03:34:16PM

sudo reboot is a harsh command, I believe you'd use all unsaved documents, I wouldn't recommend doing it this way.

Something like:

sudo osascript -e 'tell application "Finder" to restart'

Would be much better. It would get canceled if there is unsaved data.



[ Reply to This | # ]
sudo reboot, be harsh in a cruel world
Authored by: Accura on Jun 18, '03 10:23:47AM

arr, but if your using the cli to install packages most likely the box is on a remote site, so u cant press "save" or "don't save" and the restart would time out

there has to be away of avoiding this because it would be nice to be able to restart and / or log out a user via the cli

jameso

---
"The time has come," the walrus said. "To talk of many things..."



[ Reply to This | # ]
sudo reboot, be harsh in a cruel world
Authored by: WAW401 on Jun 18, '03 06:55:42PM
there is ... use VNC to control the GUI remotely. for the few times I really need GUI access to my server remotely, it's perfect. For security's sake, don't add a firewall rule to open the port. Tunnel the connection through ssh from the machine you're sitting on ... ssh -L 5900:localhost:5900 remote_ip_or_dns

Then use localhost & port 5900 in your vnc client. You can have the remote machine always running the vnc server, or run it from the ssh shell.

[ Reply to This | # ]
sudo reboot, be harsh in a cruel world
Authored by: yellow on Jan 21, '04 02:42:34PM

Of course, if you go this route, isntalling via the CLI is pointless since you can just do it via the GUI.



[ Reply to This | # ]
sudo reboot
Authored by: msk on Nov 09, '04 09:04:38AM

The applescript is all very nice, but if no one is logged into the remote machine is does not work, the response is "29:36: execution error: Application isn't running (-600)" (tested with OS X 10.3.5)



[ Reply to This | # ]
Installing packages from the command line
Authored by: semios on Jun 17, '03 05:07:18PM

This is great. Now if only I could create packages from the command line rather than using PackageMaker interactively.



[ Reply to This | # ]
Installing packages from the command line
Authored by: jyee on Dec 07, '07 07:50:38AM

You can create packages from the command line. i've done it in 10.4, but haven't tried in 10.5.

in tiger, PackageMaker will load in /Developer/Applications/Utilities/PackageMaker.app
but really all .app's are just folders, so you can call the CLI by /Developer/Applications/Uitilities/PackageMaker.app/Contents/MacOS/PackageMaker

you'll have to feed it a number of flags like -build and -p... i think there's a man page for it somewhere.



[ Reply to This | # ]
there are many GUI -> CLI utils from Apple
Authored by: finne on Jun 18, '03 09:32:23AM

If you look in /usr/sbin/ a couple of utils already stand out because of their name:

AppleFileServer
AppleSystemProfiler
DirectoryService
PasswordService
installer
softwareupdate
am-eject
nvram
system_profiler
appletalk
asr
bootparamd
disktool
screencapture
diskutil

You can find out what they do by looking at their man pages or running them (not as root obviously)



[ Reply to This | # ]
there are many GUI -> CLI utils from Apple
Authored by: krishna on Nov 10, '04 09:19:57PM

Some of these don't have man pages. Notably (for me):

opendiff - run the cocoa diff utility on two files
scselect - select network location
disktool - I'm sure this does something handy



[ Reply to This | # ]
Installing multiple packages from the command line
Authored by: lucidsystems on Dec 27, '09 05:00:54PM
You may also find installpkg to be helpful. Installpkg will allow you to easily install multiple packages with just a single command. If you have a collection of dmg's each of which has an installer in the root directory, installpkg makes installing all the packages a snap.

[ Reply to This | # ]