hello,
i’m just trying to do a schel script with administrator privileges, but even when i type one character as password i get a good respons. Only when i use a blank password i get no respons.
here’s the code i’m trying
/***************************
try
set MyCommand to “ls -al /private/var/root/”
set MyResult to do shell script MyCommand with administrator privileges
display dialog (MyResult as text)
end try
***************************/
any idee why this doesn’t work???
Sorry,
seems like in the terminal it self the commando’s work for about 5min as administrator so ones the correct password is entered it keeps workingjavascript:emoticon(‘:twisted:’)
The command you are using does not require a password to run so anything you type into the passwoard dialog window will appear to still be working except once the sudoers time stamp of 5 minutes expires you won’t see a result when typing in the wrong password. You can reset the the sudo time stamp to zero with “sudo -k”.
try
do shell script "sudo -k" --reset time stamp
set MyCommand to "ls -al /private/var/root/"
set MyResult to do shell script MyCommand with administrator privileges
display dialog (MyResult as text)
end try
Each time you run the above script, it will ask you for a password, an incorrect password will result in an error dialog.
hth
Trap the error of a bad password with the one error statement
try
do shell script "sudo -k" --reset time stamp
set MyCommand to "ls -al /private/var/root/"
set MyResult to do shell script MyCommand with administrator privileges
display dialog (MyResult as text)
on error
display dialog "bad password"
end try