Scripting Terminal - how to with SUDO

I wonder if anyone knows how to do this:

I didn't want to give anyone the admin password to switch the startup disk, but they need to do it, so the easy solution is an apple script.....

So, here is what I wrote:

tell application "Terminal"
do script with command "sudo /usr/sbin/nvram boot-device=ide1/@0:5,\\:tbxi"
end tell

Ok, but how do I give the password? I don't want to do this as a shell script since anyone can read the password, since I can compile as "read only" it is at least a little secure.

SU maybe? But then how do I set that up?

I am not to good with all this so detailed instructions are good.

Anyone know?


I believe, "echo [insert password without brackets] | sudo [insert your command]" The echo command tells the system to print the password to STDOUT and the pipe, "|" takes the STDOUT and puts it into the line right after sudo get's executes (aka the prompt for the password).

One problem with this is that if I setup a program that reads STDOUT, I can get ur password (I'm pretty sure this is trivial, but I'm not exactly sure).


Ok, here is what I got now:

tell application "Terminal"
do script with command "echo PASSWORD | su root /usr/sbin/nvram boot-device=ide1/@0:5,\\:tbxi"
end tell


[localhost:~] robert% echo PASSWORD | su root /usr/sbin/nvram boo[localhost:~] robert% t-device=ide1/@0:5,\:tbxi
t-device=ide1/@0:5,:tbxi: Command not found.
[localhost:~] robert%

Any ideas?