0
votes

I am running a script in AppleScript in which I use tell application "Terminal" to do a specific script that needs sudo privileges in Terminal. When prompted, the user running the script must enter the sudo password in Terminal to allow the script to bind the laptop to active directory.

What command can I use to get the script to stop running if the sudo password entered in Terminal is incorrect? Right now if the user enters the password incorrectly, the script will keep running the rest of the commands except it ultimately fails in the end because it is unable to bind to AD without the credentials to do so.

1
You might want to take a look at this, it may help you: stackoverflow.com/questions/20128288/…codsane
I previously looked at that before I posted by question, but I don't think that user is using Terminal to run his scriptsuser3538059
Could you post your script (just the relevant part)?Michele Percich
tell application "Terminal" activate display alert "Click OK and enter admin password to bind to AD" do script "sudo disconfigad -f -a & computerName & space & "-domain .local -u " & user name & "-p" & user_password & " -ou \ "CN=Computers,DC=,DC=local\"" delay 10 display alert "Bind successful, please wait while binding AD Admin Groups"user3538059

1 Answers

0
votes

May I ask why you're running this code specifically in the Terminal.app? When using a do shell script you can run the do shell script with administrator privileges (equivalent to sudo) and without using Terminal.app.

do shell script "disconfigad -f -a " & computerName & " -domain .local -u " & user_name & "-p" & user_password & " -ou 'CN=Computers,DC=,DC=local'" user name "<administrator>" password "<password>" with administrator privilege