You can use a command like
open /Applications/Internet\ Explorer
This is an exceptionally nice command. You can even use
open .
to have the Finder open the enclosing folder of wherever you're currently cd'ed to.
Hi,
How can I invoke a program like Internet Explorer from the command line? On Linux, you can, for example, just type netscape & in your terminal. Well, my reason for asking this is that forte wants to invoke netscape when I run a jsp. I don't have netscape and not in the mood to install the beta version of netscape for OS X. Since Forte is calling a function similiar to the way I invoke netscape from linux from command line, I am wondering if that's possible for IE. If it is possible, how do I find out what that command is? I tried IE and InternetExplorer, neither worked. When I tried to call the full path to Internet Explorer (from the Application dir) I get a permission denied error.
So, as a non-root user, how do I call Internet Explorer from command line?
Thanks!
G
You can use a command like
open /Applications/Internet\ Explorer
This is an exceptionally nice command. You can even use
open .
to have the Finder open the enclosing folder of wherever you're currently cd'ed to.
CD MHz B&W GIII Rev I; DLXXVI MB RAM; MacOS X.I.IV, IX.II.II; Give me liberty, or at least a large order of fries.
Good. I tried what you did and IE is opened as if I double clicked on the icon. The trouble is that I need to open a URL using IE. Doing the netscape way didnt work:
open /Application/IEPATH http://www.apple.com
It just ignores the path. Doing simple: open http://www.apple.com results in a file not found error.
Any clue or should I switch to buggy Netscape?
Thanks in advance!
Okay, at this point, I'd suggest doing it with a one-line AppleScript being run from the command-line. Most GUI Mac applications don't really allow for parameters to be passed to them, but do support AppleScript. The only real problem with this is that currently, I'm only getting this to work with Mozilla (and therefore Netscape). Whenever I try IE, it just uses the Classic version. Someone else could probably see a way around this. But here is what you can do for Mozilla/Netscape:
/usr/bin/osascript 'tell application "Mozilla" to GetURL "www.apple.com"'
You'll need the full path to osascript, because otherwise it probably won't run.
CD MHz B&W GIII Rev I; DLXXVI MB RAM; MacOS X.I.IV, IX.II.II; Give me liberty, or at least a large order of fries.
So I guess I will need to learn another language, AppleScript? Sad but tough luck. Any good resources where I can poke around?
Thanks!
G
Like I said, there may be other possibilities, but coming from the world of OS 9, the only way I can think of is with AppleScript. You can read up on it at http://www.apple.com/applescript/. Don't worry about difficulty, though. Scientific studies have shown that even hamsters can learn to program in AppleScript. Granted, they were really smart hamsters, but I think you get the idea.
CD MHz B&W GIII Rev I; DLXXVI MB RAM; MacOS X.I.IV, IX.II.II; Give me liberty, or at least a large order of fries.
I just thought I ought to mention that things are slightly different with OS X.I. You now don't need to include the /usr/bin part, and in order to do a one line script, you need a -e. So to do the same thing as before, just say
osascript -e 'tell application "Mozilla" to GetURL "www.apple.com"'
Internet Explorer seems to be a little trickier, for me at least. When I try using osascript on it and IE isn't already open, it tries to open the Classic version, for some reason. Fortunately, you can just do
open /Applications/Internet\ Explorer.app/ ; osascript -e 'tell application "Internet Explorer" to OpenURL "www.apple.com"' > /dev/null
Notice that IE uses OpenURL, instead of GetURL. In addition, using the "open" command on a program that is already open seems to not give an error anymore. Lastly, using osascript keeps returning "-2" when I run it, and hence the >/dev/null, because it gets annoying after a very short while.
This may seem like a lot to do for a very simple command, but there is a lot more you can do without saying much else. Plus, if you use Mozilla, Netscape, or OmniWeb, you don't need to do as much (and interestingly OmniWeb, in its quest for complete and utter compatibility, accepts both OpenURL and GetURL.)
CD MHz B&W GIII Rev I; DLXXVI MB RAM; MacOS X.I.IV, IX.II.II; Give me liberty, or at least a large order of fries.
It seems to work. But using an argument would not work because $1 is translated literally:
open /Applications/Internet\ Explorer.app/ ; osascript -e 'tell application "Internet Explorer" to OpenURL "$1"' > /dev/null
This is placed in a file ie.sh, and I wanted to do something like:
./ie.sh www.macosx.com
swapping the single quotes with the double quotes caused some mysterious syntax error. Is there anything in applescript that wll allow me to insert variables?
Thanks,
G
Bookmarks