This question already has an answer here:

I'm trying to run a package installer from terminal and have it complete with limited interaction from the user. This will need to be ran on any computer.

The bash script I have so far is:

sudo installer -store -pkg "/Users/username/Desktop/test.pkg" -target /

It will not complete and I am getting the following error: installer: Can't load package "/Users/username/Desktop/test.pkg": The requested URL was not found on this server.

Not sure what this error means as I'm a newbie to scripting. Please advise what is needed to fix this.

marked as duplicate by nohillside Jul 19 '16 at 6:25

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • The man page recommends against using -store together with sudo, you probably don't need that option anyway as it is primarily intend to test package installation before submitting them to the store. Also the error message indicates that installer can't access the package file, is it in a place where root can access it? Also, does the package itself work, i.e. can you install it by double-clicking it in Finder? – nohillside Jul 19 '16 at 6:19
  • @patrix Did you delete my comment? – jsejcksn Jul 20 '16 at 15:39
  • @jsejcksn Your comment got deleted automatically by the system when I put this on hold for being a duplicate of the question your comment linked to. It is now shown on top of the question. – nohillside Jul 20 '16 at 17:16
  • @patrix Thanks for explaining. If that was in the SE site use documentation, I missed that part. – jsejcksn Jul 20 '16 at 18:21
  • @jsejcksn You'll probably find it documented somewhere on meta.stackexchange.com. – nohillside Jul 20 '16 at 18:35

It is not possible to run any command using sudo without user interaction because the user will have to supply an administrative password.

  • OK, that is fine. Any Idea how this script would complete with limited interaction? – MacMania Jul 19 '16 at 5:54
  • @MacMania How is the script being run? Also, is the .pkg file necessary? – jsejcksn Jul 19 '16 at 5:59
  • Script is being run via bash script and yes, the package is necessary. – MacMania Jul 19 '16 at 6:00
  • See the link I commented on your question. You might be getting the error because that username doesn't exist. Try using the ~ to get to the user folder instead of the absolute path. – jsejcksn Jul 19 '16 at 6:25

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