Home » Questions » Computers [ Ask a new question ]

How can I run an application with command line arguments in Mac OS

How can I run an application with command line arguments in Mac OS

Is there any easy way to append command line arguments to an application on a Mac? For example, to run Opera in kiosk mode or to use a different profile in Firefox, I can type

Asked by: Guest | Views: 315
Total answers/comments: 5
bert [Entry]

"Here's my best solution: Create an Applescript with:

do shell script ""/Applications/Firefox.app/Contents/MacOS/firefox -P default -no-remote & killall Firefox.app""

And save it as an application.

You can put whatever application with whatever args in the first part. The part after the & needs to kill whatever you have named your script + .app. You'll see the script app flash up in the dock, but it will then disappear.

Note: The script will not work properly when run from Script Editor, only when run from the script application you have created."
bert [Entry]

"Open Automator and create an Application with a single Run Shell Script action:

/Applications/Firefox.app/Contents/MacOS/firefox-bin -here-some-args &

This application will launch Firefox and quit instantly, leaving only Firefox running.

Alternatively, create an application using AppleScript Editor with the following AppleScript code:

do shell script ""open -a '/Users/danielbeck/Applications/Firefox.app' --args -ProfileManager""

Both work fine and don't keep either Terminal or a script application running for more than a second or so. Using Automator, you can even create a Service if you choose so."
bert [Entry]

"AppleScript

do shell script ""/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --incognito & killall applet""

Two points there.

The space is escaped by a backslash which is escaped by backslash again
killall applet can cause troubles, because there may other applets running
Save it as program

However it works well on 10.6.5"
bert [Entry]

"The open command has an optional --args argument that's value will be passed on to the opened application as arguments. For example:

open /Applications/TextEdit.app --args example.txt"
bert [Entry]

"The following should let you specify command-line arguments for the .app itself:

Right click .app bundle, select ""Show Package Contents"", navigate to Info.plist, double click it, find Args key, edit.

I don't have an OS X machine handy right at the moment, so I can't check whether you could also do this to an alias (if you wanted to keep the original .app argument-free, et cetera)."