Quit script upon identity validation

Hi,

I want a script to quit when the user identity is validated and to continue when either a wrong password is entered or when cancel is pressed. The usual ‘do shell script “echo ‘’” with administrator privileges’ does exactly the opposite of what I want.

Explained in a different way:

  • Check user password
  • If correct stop script
  • Else continue script

Can this be done with shell script “echo”?

umm, what? ie what are you using echo for?

set thePass to "banana"

if (text returned of (display dialog "Please enter your password" default answer "" with hidden answer)) is thePass then return

display dialog "tra la la la la, I am the script continuing on"

I just found the solution. Stupid, I should have thought of it before…

try
	do shell script "echo ''" with administrator privileges
on error errorMsg number errorNum
	if errorNum is -128 then
		-- run the script
		say "banana"
	end if
end try

Even better:

try
	do shell script "echo ''" with administrator privileges
on error
	-- run the script
	say "banana"
end try