How do I invoke IE browser from Python on Mac OS X?

Paul Jackson pj at engr.sgi.com
Sun Oct 20 21:04:43 EDT 2002


Brian wrote:
> Don't know about Python directly, but open -a /path/to/app should work
> from a shell.  If you want to open it with a URL, though, that might not
> be sufficient.

That was fast - Thanks !!

If I can do it from the shell, I can do it from Python with
some variation of a "os.system(open -a /path/to/app)" call,
I presume (I'm not near my Mac to try right now).

I don't grok what you meant by "open it with a URL", but that
probably doesn't matter ... ah - you mean "if I want to open
the browser on a particular URL, as might happen when passing
it a command line argument".

With the hints you've given I found on a Google search:

    http://www.macosxhints.com/article.php?story=20020902074127468

    Open URLs from the command line

    Mon, Sep 2 '02 at 10:41AM . from: Anonymous In the Terminal,
    type "open http://www.apple.com" and your default browser
    will launch and open this page. I think this is only possible
    in 10.2!

    [Editor's note: I don't think this worked in 10.1, either
    (at least not according to this hint). Run "man open"
    for some other possibilities.]

A couple of link-hops away from this is Launcher:

    http://web.sabi.net/nriley/software/

    Apple provides a simple command-line launching program
    called open with Mac OS X. It offers few options--launching
    applications by name or by path, launching TextEdit,
    or opening a number of applications, documents, folders,
    etc. With the exception of special support for TextEdit,
    launch does everything open does, and:

    * opens URLs, directly or in your preferred helper application
    * lets you specify applications by their four-character creator
      (e.g. 'ToyS') or Java-style bundle ID (e.g. com.apple.scripteditor),
      both of which allow you to move or rename an application without
      changing references to it
    * asks applications to print documents, something the OS X Finder
      doesn't let you do any more
    * launches applications in the background
    * launches Carbon applications in Classic
    * reports errors intelligibly
    * shows information about any item on disk, including its file type,
      creator, data and resource fork sizes, dates and bundle ID
      (where applicable).

    launch is useful by itself, but is even better when used
    in scripts. Assign a shell command to your favorite Mac OS
    text, graphics or resource editor. Browse your favorite
    Web site with a few keystrokes. launch requires Mac OS X
    10.1 or later with Developer Tools installed.
-- 
-- 
                          I won't rest till it's the best ...
                          Programmer, Linux Scalability
                          Paul Jackson <pj at sgi.com> 1.650.933.1373



More information about the Python-list mailing list