Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bamafan

macrumors newbie
Original poster
Oct 2, 2006
2
0
I am an experienced UNIX user, and am learning the ropes with my first Mac computer. I have one of the new iMacs (Intel core duo processor) and am running OS X 10.4.

I am trying to figure out how to lanuch an application from the Terminal, and I'm having no luck. On a typical UNIX system (Sun Solaris is what I'm most familiar with), you can just type the name of the application to launch, but it's not working for me from the Mac Terminal. I have tried to execute the application using all of these methods:

<work>$ TextEdit
</Applications>$ ./TextEdit
<work>$ TextEdit.app
</Applications>$ ./TextEdit.app

All of these attempts result in the "no such file or directory" error message. I have tried to launch the apps from the /Applications directory where the actual application files exist, and still no luck. I have checked the permissions, and the applications do have executable permissions (rwxr-xr-x).

I've also added /Applications to my path, but that's not working either.

Any suggestions? Thanks.
 
The applications are actually, for the most part, folders of files (right-click on an app and select "Show Package Contents").

They're not really "made" for running directly from Terminal, but something like
Code:
/Applications/TextEdit.app/Contents/MacOS/TextEdit
will work.

Or just open a file of the appropriate type, like this:
Code:
open sample.txt
 
Here's another way to do it that's sort of a mix of jsw's examples:

Code:
open /Applications/TextEdit.app
 
jsw said:
The applications are actually, for the most part, folders of files (right-click on an app and select "Show Package Contents").

They're not really "made" for running directly from Terminal, but something like
Code:
/Applications/TextEdit.app/Contents/MacOS/TextEdit
will work.

Or just open a file of the appropriate type, like this:
Code:
open sample.txt

You can also:
Code:
open /Applications/TextEdit.app
 
Ah... I'd never used the open/app combo. Silly me. :eek: I tend not to open GUI apps from Terminal.

Yes, that's a much better approach.
 
jsw said:
...Or just open a file of the appropriate type, like this:
Code:
open sample.txt

Thanks for the quick response.

One more question: Does the "open" command launch the default application for that file type (based on the file extension)? If so, how do you update the default application? I've just installed Vim for Mac, and that's the application I'm trying to use as my editor. Is there any way I can make "open" launch Vim instead of TextEdit?
 
bamafan said:
One more question: Does the "open" command launch the default application for that file type (based on the file extension)? If so, how do you update the default application? I've just installed Vim for Mac, and that's the application I'm trying to use as my editor. Is there any way I can make "open" launch Vim instead of TextEdit?

You can update the default app graphically by right / ctrl-clicking the document and then choosing the open with.. option, selecting the appropriate item, and selecting the button to always use that app. Very similar to Windows.

I think there's also an -a flag for open that lets you specify the app....
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.