Resolved Terminal Command File

Craig McArthur

macrumors member
Original poster
Sep 2, 2011
32
0
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
 
Last edited:

balamw

Moderator
Staff member
Aug 16, 2005
19,075
963
New England
You can shorten that, but unless you are willing to hardcode your password in the script, you will still need to open Terminal.

B
 

Craig McArthur

macrumors member
Original poster
Sep 2, 2011
32
0
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

You can shorten that, but unless you are willing to hardcode your password in the script, you will still need to open Terminal.

B
 
Nov 28, 2010
22,668
27
located
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
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.
 

Craig McArthur

macrumors member
Original poster
Sep 2, 2011
32
0
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.
I'm sure I have a password, I just don't know why I bothered ;)

Have a loot at this thread on a related subject. I may be able to add more later today.

http://forums.macrumors.com/showthread.php?t=1339578

B
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!
 

balamw

Moderator
Staff member
Aug 16, 2005
19,075
963
New England
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?
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
 

Craig McArthur

macrumors member
Original poster
Sep 2, 2011
32
0
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
perfect thanks