sudo

how do i script a sudo command with the password? i’ve been trying all sorts of possibilities but come up blank.

do shell script "sudo whatever" password "your_admin_pw" with administrator privileges

See also: Technical Note TN2065: do shell script in AppleScript

ok, i took out the sudo from the command and it’s working fine now. thanks!

It’s sneaky bits like this that have held me back on upgrading from Panther to Tiger - a whole pile of scripts would have stopped working and I’d have been days trying to figure out why. I’ve always wondered why I needed sudo anyway since I was logged in as administrator.

Addition: do shell script “sudo -k” – times out sudo privileges

i’m sorry, could u explain a little bit more about sudo -k and how i should use it? i’m not entirely clear.

do shell script "sudo -k"

deauthenticates the sudo process. In other words, it erases the password from the script and exits the sudo process.