![]() |
can i launch gui apps from the terminal?
A few nights ago I was messing around in terminal and I cd'd to my applications directory and then tried to launch Interarchy.app. A whole mess of garbage suddenly filled the terminal screen (until I pressed ctrl-C). Switching back to the gui applications folder I saw that a bunch of 0 K files had also been created with cryptic names like "8" and "6e" and "8 followed by a Japanese character." I moved those files to the trash and after restarting (for a different reason) the files had been deleted. There haven't been any ill-effects from my "experiment" thankfully.
1. Can one launch an app from the Terminal. 2. What were the screen garbage and the extra files about? Thanks, Glenn |
Use a command called Open
Yes you can launch applications from the Terminal. The following method works for me.
When you are in the same directory as the app (application) you want to open, simply type in: open Mail.app This command will open the Mail application. I hope... Can't help you with your other question about the files, as I don't know. Good luck. Herod |
The reason you got garbage is that Interarchy is a Carbon app and cannot be started with its name on the command line. You have to use:
/System/Developer/Tools/LaunchCFMApp /Application/Interarchy When you typed ./Interachy at the prompt, you "tried" to start a mach-O binary (the "new" format of programs) even though it was not. You got garbage because it tried to run it as a shell script. The open command is what you are looking for and is *very* useful. It is *identical* to a double click in the Finder. For instance: Open the current directory in the finder: open . Open a document: open documentname Open a document with an application: open -a Application file For instance, I made a trivial script that opens files in BBEdit. Paste this into a file in a directory bin that you create in your home directory. Call the file bbedit: -------------------- #!/bin/sh open -a /Applications/BBEdit\ Lite\ 6.1/BBEdit\ Lite\ 6.1\ for\ OS\ X $1 --------------------- then make the file executable with chmod ogu+x ~/bin/bbedit and now you can type: bbedit /etc/rc or whatever else (as long as you own the file though: bbedit will warn you if you don't). Pretty useful. |
Or you can type the path to the application or document: open /Applications/iPhoto.app, for example.
When you're in a terminal sometime, type man open and you'll see some brief directions about how the open command works. |
Thanks for all the replies. Already these forums have proved helpful.
Best, Glenn |
Novajo: you raise an interesting question:
How can you tell in advance if an app is mach-o or CFM, and which method you need to use to launch it? |
Is it Carbon or mach-o ?
I guess I would use resEdit, open the file and look for 1) a resource fork. If there isn't any, it can't be Carbon, it's therefore Mach-o. 2) If there is one, it's highly likely a Carbon app. Look for a 'carb' resource (and associated 'code' resource). If you find it, it's Carbon.
You can use a program called Carbonic that does just that (I guess). But honestly, I would just try both. If it crashes when you type just the name, then it's Carbon. :-) |
Don't you think this is all a wee bit beyond all UNIX newcomers? I'm pretty new myself, but times would have been when all this jargon would have put me off trying out the terminal and all the UNIX stuff. Maybe we should try keeping this forum as simple and straightforward as possible?
|
Re: Is it Carbon or mach-o ?
Quote:
Ellen |
X-Ray
Alright, X-Ray! There must be something in the package contents that tips this off?
|
command line open app shortcuts
this will be heavy for unix newbies, but you can't learn without doing...
what you really want is short shortcuts to what you want/need to access create symbolic links to your apps you want to access via command line, e.g. ~% ln -s "/pathto.../bbedit 6.5/bbedit 6.5" foo you can give these symlinks shorter names than the target now, from your home directory, simply... ~% open foo referencing foo dereferences the path to your bbedit app caution: symlinks and finder aliases are not the same. finder aliases are rather forgiving if you rename/move the target around. symlinks plain break. so have a static organization in place before you create umpteen symlinks. static organization is a whole nother bag of cats. |
Reading is Optional
No disrespect intended but if someone posts a reply and it sounds complicated then maybe that's a sign that you should file the post for future reference for when you've learned more. The important thing is that the answer is there and anyone can read it if they like.
It would be rude of the poster to say something like "It can be done but this is a newbie forum so I won't tell you how to do it." Better to just give the process and let the reader decide if it's something she/he wants to try. When I'm grovelling through online documents about Linux software often times I run into really impenetrable stuff but I'd rather it be there than not because there may be a concept or two in their I can understand and from there I might be able to figure out the rest. I realize that this is a Newcomers forum but, honestly, if the poster had placed the response in an "Advanced" forum you might never see it not to mention that fact that posting an answer outside of a thread is kinda psycho. :D Quote:
|
Re: command line open app shortcuts
OK, man, you just killed all the newbies with this post! :D
What I've found is that I just remember all the paths in all their inscrutable glory (on my Linux systems anyway). The presence of spaces in folder and file names kills me when I'm on the OS X box because I have to S-L-O-W D-O-W-N to type the escape-slashes, e.g. Adobe\ Photoshop\ 6.0 Quote:
|
OK, very simple....:
To open an application:
Say you want to open Mail in the terminal type: /Applications/Mail.app/Contents/MacOS/Mail & (the '&' at the end of the of the command is for running the app in the background, which is what OSX normally does) For those of you with little OSX knowledge: An (Cocoa) application under OSX is actually a directory which contains several resources. One of them is the 'MacOS' directory in the 'Contents' dir (see example command). This dir contains the actual executable, which usually has the same name as the application. To open a document from the terminal: say you want to open a Rich Text Format document in the terminal type: open SomeDocument.rtf What happens here is that OSX (or Darwin) looks for the application associated with the document. |
Hey this is great stuff.
I am new to UNIX under OS X having dabbled minimally with SUN SPARC stations at work. I am beginning to see the power of this beast (and the dangers!) I am on a mission to learn enough UNIX to go to the pub with you guys and not look an idiot! I know quite a few commands by heart now, especially after setting up "simlinks" or whatever to allow seperate partitions for Users, Apps and Swap on my machine. I am SO glad I have a Mac. |
HyperHerod has a point though, let's try to explain the jargon as we go into it, assuming that the language has been as large a reason for the vaunted 'user-unfriendly' reputation of UNIX as the actual usage of it has been.
so, for my part, in the above discussion: mach-o = an executable file (Program) format that is native to Mac OS X, and therefore gains the best speed and feature support. CFM = Code Fragment Manager, an executable (Program) format used by Mac OS 9 and earlier for PowerPC applications, and still used by many (but not all) Carbon apps on OS X. There are some extra layers of software required in OS X to run these, so they are slower and less feature-rich. |
I am very new to OSX and a complete UNIX Novice, but this stuff is great.... keep it coming!
|
aalegado,
----- OK, man, you just killed all the newbies with this post! ----- ::holstering weapon:: whoops, sorry ------- What I've found is that I just remember all the paths in all their inscrutable glory (on my Linux systems anyway). The presence of spaces in folder and file names kills me when I'm on the OS X box because I have to S-L-O-W D-O-W-N to type the escape-slashes, e.g. Adobe\ Photoshop\ 6.0 -------- tab, man, tab learn your shell completions; hitting tab (in tcsh, anyhow) will fill in all the encoding needed to make a properly formed path ===== craig, the unix file command will also signify a file's binary nature... ~% file bin/df bin/df: Mach-O executable ppc ~% file xapps/MP3\ Rage\ 4.2/ xapps/MP3 Rage 4.2/: directory ~% file xapps/MP3\ Rage\ 4.2/MP3\ Rage xapps/MP3 Rage 4.2/MP3 Rage: CFM binary ~% file /Applications/iTunes.app/Contents/MacOS/iTunes /Applications/iTunes.app/Contents/MacOS/iTunes: CFM binary ~% file Pictures/pix_/49_lampshade.jpg Pictures/pix_/49_lampshade.jpg: JPEG image data, JFIF standard sometimes you have to dig into the app package to find the executable |
Too hard!!
I think you guys typing/tabbing out the full paths to applications *are* making it too hard!
What's wrong with a nice simple open -a mail to open /Applications/Mail.app, or open -a terminal to open /Applications/Utilities/Terminal.app or even open -a 'disk copy' to crank up /Applications/Utilities/Disk\ Copy? Cheers, Paul |
good one, pmccann,
the open -a command does a nifty search to find the application, even if it's not on the root file system Code:
% find /Volumes/chunder/xapps/ -name OmniDictionary.appkaboom, there it is. |
| All times are GMT -5. The time now is 10:22 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.