0

Hello,

I am creating an AppleScript where it is easy to install Java with one-click for the clients. When the AppleScript is executed it will check for Java and if not found download and install it automatically. It is fine until the downloading part. The below can be done in Terminal console manually to run silently,

sudo -S installer -verbose -pkg your_installer_file.pkg -target /

What I want is to do this in AppleScript automatically. What is the code line to achieve what is done in Terminal console?

0

1 Answer 1

3

To run a shell command with sudo privileges you have 2 options:

  • With [the usual GUI] password prompt:
do shell script "installer -verbose -pkg your_installer_file.pkg -target /" ¬
  with administrator privileges
  • Fully automated, with sudo (username and) password hard-coded into your statement [NOT RECOMMENDED for obvious reasons]:
do shell script "installer -verbose -pkg your_installer_file.pkg -target /" ¬
  user name "{SudoUserHere}" password "{PasswordHere}"  ¬
  with administrator privileges

If the executing user is the desired sudo user, the user name clause is optional.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.