Resolved Terminal Command File

Discussion in 'Mac OS X Lion (10.7)' started by Craig McArthur, Mar 19, 2012.

  1. Craig McArthur, Mar 19, 2012
    Last edited: Mar 20, 2012

    Craig McArthur macrumors member

    Joined:
    Sep 2, 2011
    #1
    Hi

    Is it possible to make a terminal file with a command in it so I can run the command just by opening a file?

    In case you're curious the command is
    Code:
    sudo killall coreaudiod
    and the reason is because I swap out my headphones for speakers a couple of times a day and for some unknown reason it stuffs up and stops making any sound at all from any sound output until I run this command and enter my password.

    Many thanks
    Craig
     
  2. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    You can shorten that, but unless you are willing to hardcode your password in the script, you will still need to open Terminal.

    B
     
  3. Craig McArthur thread starter macrumors member

    Joined:
    Sep 2, 2011
    #3
    Hi Balam thanks for the quick reply.

    I don't mind adding the password - I'm not even sure why I have one, I seem to auto-log-in anyway.

    Thanks
    Craig

     
  4. simsaladimbamba

    Joined:
    Nov 28, 2010
    Location:
    located
    #4
    Do you enter a password when you install some heavier applications?
    Just because your Mac is set to auto login, does not mean, you don't have a password. You can check via System Preferences > Account.

    As to your problem, you could look into Automator or a Shell Script.
     
  5. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #5
  6. Craig McArthur thread starter macrumors member

    Joined:
    Sep 2, 2011
    #6
    I'm sure I have a password, I just don't know why I bothered ;)

    Thanks for the link. I think Automator will be the best option, but I can't make heads or tails of it - how do I make an application that executes "sudo killall coreaudiod" that passes my password automatically?

    Balamw, love the link by the way! Quite a back and forth!
     
  7. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #7
    Automator -> Application -> Run Shell Script

    remove

    Code:
    cat
    and replace with
    Code:
    echo "[PW]" | sudo -S killall coreaudiod
    Where you also replace [PW] with your password.

    Just be aware that this lowers the security of your system and password, if you don't care, you don't care. As I mentioned in the other thread. sudo expects you to have a password and will generally not work if you don't, e.g. if you insist on having a blank password.

    B
     
  8. Craig McArthur thread starter macrumors member

    Joined:
    Sep 2, 2011
    #8
    perfect thanks
     

Share This Page