Double-clicking a shell script as superuser

Discussion in 'Mac Apps and Mac App Store' started by Doctor Q, Sep 2, 2004.

  1. Doctor Q Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #1
    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!
     
  2. yippy macrumors 68020

    yippy

    Joined:
    Mar 14, 2004
    Location:
    Chicago, IL
    #2
    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.
     

Share This Page