image
image

|


Go Back   macosx.com > Mac Help Forums > HOWTO & FAQs

Reply
 
Thread Tools
  #1  
Old February 26th, 2003, 01:41 PM
Registered User
 
Join Date: Aug 2002
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Kiup is on a distinguished road
[HOW TO] Launch Application from Terminal?

How do I launch an application from the terminal?

Thanks for the help
Reply With Quote
  #2  
Old February 26th, 2003, 05:47 PM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
Opening Applications from the command line

The command is simply open (which can also be used for opening directories). The most basic example of launching an application:
open /path/to/some.app

More complex possibilities also exist:
open "/Volumes/Macintosh HD/foo.txt"
opens the document in the default application for its type (as determined by LaunchServices).

open /Applications/
opens that directory in the Finder.

open -a /Applications/TextEdit.app "/Volumes/Macintosh HD/foo.txt"
opens the document in the application specified (in this case, TextEdit).

open -e "/Volumes/Macintosh HD/foo.txt"
opens the document in TextEdit (the -e option specifies TextEdit).

open http://www.apple.com/
opens the URL in the default browser (lynx, naturally *wink*)

open "file://localhost/Volumes/Macintosh HD/foo.txt"
opens the document in the default application for its type (as determined by LaunchServices).

open "file://localhost/Volumes/Macintosh HD/Applications/"
opens that directory in the Finder.
Reply With Quote
  #3  
Old February 26th, 2003, 05:53 PM
Registered User
 
Join Date: Aug 2002
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Kiup is on a distinguished road
Thanks allot, very simple, just couldn't seem to find the info anywhere. Thanks again!!!
Reply With Quote
  #4  
Old February 26th, 2003, 06:14 PM
~departed~
 
Join Date: Jul 2002
Location: Kansas City, MO
Posts: 457
Thanks: 0
Thanked 0 Times in 0 Posts
gatorparrots is on a distinguished road
Opening applications with root privileges

If you need to edit a root-owned system configuration file, it is possible to do so with a graphical text editor, for example.

Carbon Applications
Older Carbon applications have to be run via LaunchCFMApp because they are in the wrong binary format for Mac OS X, so LaunchCFMApp handles the necessary translation.

To launch a Carbon application directly (without using open), one has to actually run LaunchCFMApp, giving it the application as an argument:
/System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/path/to/some/application'.

open can also be used to launch Carbon applications. open simulates a double click, hence the package name is given, rather than the full path to the executable. open's main advantage is in opening documents since it uses the Finder's 'open with' database of what applications open what documents, and in opening Carbon applications. Using open, most of the difficult work is done for you: open '/path/to/some/application'

To launch a Carbon application with root privileges, you have to prepend sudo -b to the first command above. Here is a specific example:
sudo -b /System/Library/Frameworks/Carbon.framework/Versions/Current/Support/LaunchCFMApp '/Applications/BBEdit Lite 6.1/BBEdit Lite 6.1 for OS X'

Cocoa Applications
To run applications as root, we use sudo. However combining open and sudo in this form:
sudo open /path/to/some.app
results in sudo running open as root, but open still opens the application as the original user!!!

Therefore, the longer method of specifying the full path name for Cocoa applications (not just to the .app package, but to the actual executable):
sudo "/Applications/TextEdit.app/Contents/MacOS/TextEdit"

(The -b flag can be specified to run appropriate applications in the background. You can't use & and sudo when an authentication password is required, necessitating the need for the -b flag.)

Last edited by gatorparrots; February 26th, 2003 at 06:21 PM.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using applescript to open web browser and go to a site blackoutspy Software Programming & Web Scripting 9 August 12th, 2003 11:26 AM
[HOW TO] Terminal berniech Unix & X11 8 February 24th, 2003 02:26 PM
Script to open terminal and launch telnet huck Unix & X11 3 September 17th, 2002 07:43 PM
Application won't launch in Classic mala Mac OS X System & Mac Software 1 December 12th, 2001 07:34 PM


All times are GMT -5. The time now is 11:59 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.