1

I'm trying to find a way to automatically launch a command when Terminal is run, but:

  1. Have the Terminal window close after command has returned control to it / after (using &) after command has started launching.
  2. Not have the user change any settings themselves / not have the settings changed globally.

I have found (mainly from a relatively very comprehensive write-up on http://docstore.mik.ua/orelly/unix3/mac/ch01_03.htm) the ability to create a .terminal file and edit the contents (plist) to contain xml like the below.

    <key>ExecutionString</key>
    <string>ssh xyzzy.oreilly.com; exit</string>

However:

  1. Given the date of other postings (on google) showing this functionality
  2. The fact that the procedure which I eventually found to create custom Terminal windows, was subtly different from the instructions in the article above
  3. The fact that (at least with OSX10.5) they are now .term files (and complain that the file is not executable if changed to .terminal)

... am guessing that some version of OSX, post all the information I can find on this technique, changed this functionality. Is this correct in any version of OSX 10.5+?

Also, is there still a way to launch a command automatically in a custom terminal window (or similar, that isn't AppleScript / Automater / etc)?

6
  • When does the program run - how does the user start it? And why not automator?
    – mmmmmm
    Commented Jan 19, 2013 at 20:19
  • It's not very clear to me what exactly you are trying to do. Your description is confusing. Maybe you can express your question in a more concise way?
    – Gerry
    Commented Jan 19, 2013 at 20:37
  • Mark - Currently we supply instructions to clients to create a .command file to run our program on certain machines that need the arch programs functionality to run properly, so the .command program is run ad-hoc. However, unless the user has set the Terminal program to close on shell closure (either with the condition of last command finishing cleanly, or not), the best we can do is exit and have the Terminal window stay open with [Process Completed] in it, which seems pointless as our program doesn't output anything to stdout. A custom terminal with the above xml seems to be ideal.
    – user66001
    Commented Jan 19, 2013 at 20:52
  • @Gerry - What is confusing... The entire concept, or certain aspects? Are you familiar with this ¿old? functionality of .terminal files?
    – user66001
    Commented Jan 19, 2013 at 20:55
  • If you are getting money for this I would suggest the professional way is to write an objective C wrapper program that class fork or exec and have all the programs syored in the app bundle
    – mmmmmm
    Commented Jan 20, 2013 at 14:37

1 Answer 1

2

ExecutionString was changed to CommandString Use it in the same way. When you do a Shell > Export Settings… it outputs a .terminal file. In my file it is located immediately after

<key>BackgroundSettingsForInactiveWindows</key>
<true/>
<key>CommandString</key>
<string>/blah/blah/blah/blah.sh run</string>

(MountainLion 10.8.5)

So then you would run the following command from terminal or a script…

open ~/Documents/blah.terminal

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .