Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want /Users/me/dir/executable to run every time I log in.

You can think of the executable as basically a text file that has executable permissions and contains something like this: javaws http://some/url

The previous sentence might be the key to the answer. Executing something like chrome doesn't leave behind a Terminal window but executing the text file does.

I've configured a Login Item that points to this executable text file and I've checked the Hide check-box (not sure what that does).

Now, every time I log in there is a Terminal window associated with this login item. The window says

Last login: (timestamp)
/Users/me/dir/executable ; exit;
machine:~ me$ /Users/me/dir/executable ; exit;
logout

[Process completed]

I've learned that I need to uncheck Reopen windows when logging back in so that prevents these windows from accumulating over time. But I'd like to hide/eliminate the window entirely.

How can I have a Login Item that doesn't leave behind a Terminal window?

Note: I've considered using launchd. But the thing I want to run has/wants a UI so running it hidden in the background isn't what I want to do.

share|improve this question

migrated from stackoverflow.com Jun 25 '13 at 17:05

This question came from our site for professional and enthusiast programmers.

1  
you should look into launchctl or one of the shell mechanisms... –  Grady Player Jun 25 '13 at 16:38
    
"Startup items and launchd daemons are used to launch processes that run in the background like Apache or MySQL. Login items are meant for general applications (like Mail or Text Expander) that usually have some kind of user interface" -- acousticwebdesign.net/programming/… –  user1011471 Jun 25 '13 at 18:05
    
what you are ultimately launching... it has a UI but, you want terminal to not open. Is that what you are going for, it isn't entirely clear. –  Grady Player Jun 25 '13 at 19:25

1 Answer 1

up vote 0 down vote accepted
  1. Create a one-line AppleScript:
    do shell script "/Users/me/dir/executable"

  2. Save As Application "MyScript.app" (without Startup Screen)

  3. Add MyScript.app to login items.

The original poster had effectively created a shell script file. If that is added to the Login Items, the OS X Launch Services will open the Terminal application to process the script. This will open a Terminal window as the OP had explained. The default behaviour of Terminal is to leave a Shell window open when the shell exits. That can be changed as a global Terminal preference, but this may not be desirable and even if you do, the Terminal application will remain open.

The "do shell script" command in AppleScript opens a silent shell process, returns any output to AppleScript and closes the shell. An AppleScript saved as an executable app runs silently and exits (unless you specify user interaction via dialogs, etc.). The two-step solution may appear clumsy, but apart from going to the effort of setting up a launchd process, I know of no other way.

A launchd would also work as a launchd can spawn a process with a UI.

share|improve this answer
    
Can you expand on that? That explains very little, and does not look professional –  Canadian Luke Jun 25 '13 at 23:48
    
The original poster had effectively created a shell script file. If that is added to the Login Items, the OS X Launch Services will open the Terminal application to process the script. This will open a Terminal window as the OP had explained. The default behaviour of Terminal is to leave a Shell window open when the shell exits. That can be changed as a global Terminal preference, but this may not be desirable and even if you do, the Terminal application will remain open. –  Dave in Australia Jun 26 '13 at 0:22
    
The "do shell script" command in AppleScript opens a silent shell process, returns any output to AppleScript and closes the shell. An AppleScript saved as an executable app runs silently and exits (unless you specify user interaction via dialogs, etc.). The two-step solution may appear clumsy, but apart from going to the effort of setting up a launchd process, I know of no other way. –  Dave in Australia Jun 26 '13 at 0:35
    
A launchd would work for the OP as a launchd can spawn a process with a UI. –  Dave in Australia Jun 26 '13 at 1:16
    
Thanks for the update. Can you Edit your answer to add that? –  Canadian Luke Jun 26 '13 at 2:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.