Open application via. command line with parameters - Multiple times

I'm using ANT to compile a program, then launch in FireFox ... I've looked all over for a solution to this, but have yet to find one.

I need the command to open a specified URL in FireFox... easy enough, right?

Solution #1 was to use the "open -a" command, with the URL- so "open -a FireFox.app/ http://someURL.com" ... the problem with this is that it opens a new window or tab every time- its a minor annoyance, but when you do 100 or more compiles during the day, its quite annoying.

Solution #2 is to actually launch the program executable (FireFox.app/Content/MacOS/firefox) using the argument -url and that makes it so FireFox opens the URL in the current & front-most window. This worked great the first time, second time I get an error saying "A copy of Firefox is already open. Only one copy of Firefox can be open at a time."

Anybody know how to make it so I don't have to close a window every time I compile? Your help would be greatly appreciated.

Thanks!
-Eric

Unibody Macbook, Mac OS X (10.5.7), Cinema LED Display

Posted on May 25, 2009 1:20 PM

Reply
4 replies

May 25, 2009 5:19 PM in response to eheaton

Do you have to use FireFox?

The only thing I can see coming close in FireFox is an AppleScript (launched via osascript):

osascript -e 'tell application "FireFox" to get URL " http://www.macnn.com " inside window 1'


but this opens the page in a new tab.

Other browsers are more AppleScript friendly and you can probably get closer. For example, this works in Safari:

osascript -e 'tell application "Safari" to set URL of document 1 to " http://www.apple.com.com/ "'

May 25, 2009 11:17 PM in response to eheaton

It's trivial to launch Firefox to open a URL - you've already discovered that. The issue is how to get it to reopen a URL (or open another URL) without either a) trying to invoke another copy of Firefox or b) open a new window.

Passing in the URL to open is not the issue here. The issue is how to get the current app to reload a URL. Off-hand I can't see any way of doing that.

May 26, 2009 2:30 PM in response to Camelot

If it is the same URL all the time, could you find a way to issue a Command-R and thus force a refresh?

I know that Firefox does NOT have an Applescript method that does this, however there are ways to get Applescript to send a key command to an application. Asking this kind of question in the Applescript forum may give you some help, or some Google searches for using Applescript to send keycodes to an application.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Open application via. command line with parameters - Multiple times

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.