PDA

View Full Version : Double-clicking a shell script as superuser




Doctor Q
Sep 2, 2004, 04:51 PM
I have written a shell script ("fixup") that a teacher uses. (The purpose of the script isn't relevant to my question, but it's to fix a file that ends up wrong when she creates a netboot image with Carbon Copy Cloner.)

She currently runs the script in Terminal using sudo or su and typing the superuser (root) password. i would like to make it double-clickable instead so she doesn't need to type commands in Terminal. I started by making file fixup.command, which has the necessary command to invoke the shell script.

Now what? I know she needs to be prompted for the superuser password. I vaguely remember there is an application you can drag a command file into, and it will prompt for the superuser password and then execute the command. Am I remembering right? What is it's name? Is that all I need? Can I make this work by double-clicking something instead of having to remember to drag and drop?

Thanks!



yippy
Sep 2, 2004, 05:36 PM
Are you using Applescript? That would be the easiest. You can have applescript prompt for the password. Dont remember the command off hand. and then have:

tell application "terminal"
do shell script "sudo [put your script here]"
do shell script [variable for password]
quit
end tell

Something like that, then save it as an application and you have it double clickable.