|
#1
| |||
| |||
| Starting Applications from the console Hi, Can anyone explain how I can start an application from the console. Often I want to view a file from the current directory and I simply want to start an application to view it. I'd also like to be able to start a Finder window in the current directory. I've added the ability to start a console from the Finder, but it would be very useful to do the reverse! This was easy in Windows, you simply had to know the .exe name of the application. I've tried all sorts on OSX with no success. In particular, I want to start Safari, Firefox, TextEdit, and Finder.. Thanks for your suggestions! Alex |
|
#2
| |||
| |||
| You need to know the path to the binary executable, What you normally see as an App is really a folder. If you right click on an app you’ll see an option to “Show Package Contents”. You’ll find the executable in the MacOS folder within the package. For example — TextEdit, the command: /Applications/TextEdit.app/Contents/MacOS/TextEdit will launch TextEdit from within Terminal. |
|
#3
| |||
| |||
| Thanks simbalala, I can launch Safari with /Applications/Safari.app/Contents/MacOS/Safari and it starts OK. I tried creating a symbolic link to it from my ~/bin directory using.. ~/bin :ln -s /Applications/Safari.app/Contents/MacOS/Safari ~/bin :ls -l total 184 lrwxr-xr-x 1 alex staff 46 Apr 19 19:53 Safari -> /Applications/Safari.app/Contents/MacOS/Safari and sure enough got the link, but when I run it I get.. ~/bin :Safari 2008-04-19 19:53:58.092 Safari[6756:10b] No Info.plist file in application bundle or no NSPrincipalClass in the Info.plist file, exiting Any ideas what's wrong with that? Same thing happens with TextEdit symbolic link. I'm running Leopard if that's any help. Another thing that's been bugging me... some applications I can start from the console - that are simple executables - but the window focus doesn't switch to them when they start. I always have to click on them with the mouse. Does anyone know how to make that happen automatically? Thanks, Alex |
|
#4
| |||
| |||
| Im not quite sure what youre wanting to do but if your primary need is invoking TextEdit from the command line have a look at TextWrangler, its a free minimized version of BBEdit (which I have). You can install an included command line tool in both TextWrangler and BBEdit. So you can be in Terminal in any directory and just open a file with this command (I'll use /private/etc/hosts as an example and I've already "cd'd" to /private/etc). bbedit hosts (for TextWrangler the command is simply 'edit hosts') This opens hosts in BBEdit and pops BBEdit to the front. You can also save files owned by root by clicking the pencil icon on the far left when it has a red slash though it. Last edited by simbalala; April 20th, 2008 at 02:44 PM. |
|
#5
| ||||
| ||||
| You can't separate the executable from the application package. Even creating a symbolic link will not work, because once launched, the process will only be aware of the symbolic link's location, not the exectutable's true location. It will then search for necessary files from the package relative to the path of the symbolic link, which obviously will not work. I guess the easiest way to get equivalent functionality would be to create a shell script which simply launches TextEdit (using the full path), and then put that shell script in ~/bin and call it "TextEdit". As for opening Finder windows, try this: Code: open . ![]() |
|
#6
| ||||
| ||||
| Quote:
this little app will do it for you. Its amazing what a person can find with a google search. jb.
__________________ ROFL: (Rolling on the floor laughing.) Typically used by people who are too lazy to press the rest of the keys on their keyboard needed to communicate in English. |
|
#7
| ||||
| ||||
| You can launch .app packages using the Terminal using the shell command "open", like Mikuro says. For example, you can launch TextEdit from the Terminal by executing the following command: Code: open /Applications/TextEdit.app You can also provide command-line arguments in this fashion with some applications. For example, if I wished to launch TextEdit from the command line and have TextEdit open a document named "test.txt" on my Desktop (as if I simply double-clicked the document on my Desktop to open it in TextEdit), I could do the following: Code: open /Applications/TextEdit.app ~/Desktop/test.txt
__________________ Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server 1024MB 3 x 120GB + 320GB DVR-111D 2 x Radeon 7000 PCI 2 x 17" CRT MacBook 2.0GHz Core 2 Duo - White 10.5.5 2048MB 80GB CD-RW/DVD-ROM iPod Photo 60GB iPod nano 1GB AT&T DSL 6Mb/768k http://www.jeffhoppe.com |
|
#8
| |||
| |||
| Brilliant! Thank you so much guys! "open" will save me so much time and tedium. FYI - Open Terminal is the Finder Extension I am already using. Highly recommended!asdf |
![]() |
| Thread Tools | |
|
|