Bash .command script - Prompt for sudo password in Finder?

Discussion in 'Mac Programming' started by BrianFD3S, Dec 10, 2008.

  1. BrianFD3S macrumors member

    Joined:
    Feb 19, 2008
    Location:
    Ireland
    #1
    Hi all. I'm writing a bash script that I'm saving as a .command file so it can be executed through the Finder. However, it involves some commands that need sudo privileges, and rather than have the person using it have to enter their password in "scary Terminal", I would like Finder to prompt them to enter their sudo password. Is this possible?
    Thanks
     
  2. Baron58 macrumors 6502

    Joined:
    Feb 19, 2004
    #2
    You can use osascript -e to run an applescript command to throw up a GUI dialogue. Set the result of that dialog as a variable, then use that variable in an 'expect' script within your shellscript to do the sudo'ing.
     
  3. BrianFD3S thread starter macrumors member

    Joined:
    Feb 19, 2008
    Location:
    Ireland
    #3
    Hmm, ok thanks. Also, it seems that .command files must be chmod +x/755'd before you can run them.. this file is going to be uploaded and the whole point is so people don't have to to interact with the terminal :/
     

Share This Page