Running a command line app with sudo and password automatically on OS X startup
- by Designer023
I need to run an app at startup/login on my mac. I want it to launch in the background and start doing it's work without interrupting me or me having to start it up because I invariably forget and then when I need it, it wasn't running!
I have tried using AppleScript to tell Terminal to run it and type my password in, but it ends up opening multiple Terminal windows and not working. Ideally I need a script that I can just add to the user login items and it will run for me.
The app has no way of taking a password argument either and it has a password as well as the sudo! I need a solution that can either be done as an applescript (which can be made into an executable) or i need a commandline script but I have no idea about them.
This is the manual code I type
$ sudo serverStatus
password:123456
password:serverpass
My AppleScript:
tell application Terminal
activate
do shell script "sudo serverStatus"
delay 5
do shell script "123456"
delay 2
do shell script "serverpass"
end tell