The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniWeb General (http://forums.omnigroup.com/forumdisplay.php?f=8)
-   -   Is it possible to 'pipe' something into OmniWeb (http://forums.omnigroup.com/showthread.php?t=1745)

jem 2006-09-21 08:47 PM

Is it possible to 'pipe' something into OmniWeb
 
Is it possible to 'pipe' something into omniweb from the command line?

philonous 2006-09-21 09:34 PM

[QUOTE=jem]Is it possible to 'pipe' something into omniweb from the command line?[/QUOTE]

Hmmm. I have no idea if this will work, but if omniweb is your default browser and the input that you wish to pipe is to be opened with the default browser, then you can simply pipe the output to the "open" command.

grep [url]http://www.somesite.com[/url] index.html | open

Alternately, you should be able to pipe it to the actual Omniweb binary file. The path to this is (assuming you have it in Applications)
/Applications/OmniWeb.app/Contents/MacOS/OmniWeb

You can do this with any app. I used to do it with Firefox (when I wanted Bluefish, a superb gnome html editor, to launch the html preview in a non-x11 browser), but the problem with Firefox was that calling the binary directly from the command line would launch an entirely new instance of the app, instead of opening a new window or tab. I'm ASSUMING that OW will behave the same way, but it may not.

HTW.

P

jem 2006-09-21 09:51 PM

Thanks for the suggestions,
[QUOTE=philonous]
grep [url]http://www.somesite.com[/url] index.html | open
[/QUOTE]
I tried
[CODE]cat index.html | open[/CODE]
which doesn't work, the open command doesn't know which program to launch (I guess). I then tried
[CODE]cat index.html | open -a OmniWeb[/CODE]
Which works in the sense that OmniWeb becomes the frontmost app but it seems like OW doesn't read anything from stdin. I could of course make a temporary file but I would like to avoid that ... but it's a fallback alternative.

[QUOTE=philonous]Alternately, you should be able to pipe it to the actual Omniweb binary file. The path to this is (assuming you have it in Applications)
/Applications/OmniWeb.app/Contents/MacOS/OmniWeb
[/QUOTE]
This seems to behave like Firefox, OW tries to launch a second time.

Len Case 2006-09-22 09:05 AM

Because we ship our own copy of WebKit and we need it to load instead of the system one, you can't directly run OmniWeb as you showed--if you do you will end up with an OmniWeb window but no Menu (the previous app's menu will still be there).

This is because the executable specified in the Info.plist is actually OmniWeb-Launcher. I haven't had much luck launching that directly either.

philonous 2006-09-22 12:47 PM

[QUOTE=jem][CODE]cat index.html | open[/CODE]
which doesn't work, the open command doesn't know which program to launch (I guess). I then tried
[CODE]cat index.html | open -a OmniWeb[/CODE]
Which works in the sense that OmniWeb becomes the frontmost app but it seems like OW doesn't read anything from stdin. I could of course make a temporary file but I would like to avoid that ... but it's a fallback alternative.[/QUOTE]

Ok. The problem, I would venture, is that the output is somehow not formatted correctly for open.

For example, if you simply try
[FONT="Courier New"]open [url]http://www.omniweb.com[/url][/FONT]
you get the desired outcome.

I tried the following:
[FONT="Courier New"]echo [url]http://www.omniweb.com[/url] | open [/FONT]
and then I got the error that you got.

Open seems to be an OS X thing, and not a standard Unix command. The man pages say that it "first appeared in Nextstep". I defer to the OG people on this one.

Now, what x11 apps (like Bluefish) do is that they echo something like "open %s", where %s is, of course, the string value of the s variable, which contains the name of the html file. So, if you know any shell scripting, maybe you can try storing the value of the URI into a string variable, and then piping the string value to the open command.

This should work, damnit, even though it's a bit of work! Hopefully open will become more Unix-like in the future. Perhaps something to bother Apple with? :)

P

jem 2006-09-22 01:12 PM

I think that are two reasons

+ When I pipe something the 'open' command can't determine what kind of data is sent to it ... should it for example open BBEdit, Mail or OmniWeb ... so unless I specify the app, open doesn't know what to do. If I use a file the it can use the file extension to figure out what to do (the same if I use an url)

+ OmniWeb doesn't understand that it should read data from stdin

The man page for open seems to support my first guess, as for the second I have no idea if it's correct or not

philonous 2006-09-22 01:59 PM

[QUOTE=jem]+When I pipe something the 'open' command can't determine what kind of data is sent to it ... should it for example open BBEdit, Mail or OmniWeb ... so unless I specify the app, open doesn't know what to do. If I use a file the it can use the file extension to figure out what to do (the same if I use an url)

+ OmniWeb doesn't understand that it should read data from stdin

The man page for open seems to support my first guess, as for the second I have no idea if it's correct or not[/QUOTE]

Len explained the problem with OmniWeb, and you are correct about the problem with pipe. I thought the problem was with open, but when I try
[FONT="Courier New"]echo [url]http://www.yahoo.com[/url] | lynx [/FONT]
the command fails, even though
[FONT="Courier New"]lynx [url]http://www.yahoo.com[/url][/FONT]
works.

In the former case (the failure), what happens is that the letters are executed as lynx commands after lynx has launched.

So, the problem does seem to be how commands like lynx and open handle parameters that are piped to them.

I think that the workaround is to use some scripting to construct the correct expression using open, and executing that single expression.

P

Len Case 2006-09-23 01:31 AM

It sounds like 'jem' wants to open arbitrary html without writing it to a file first--this isn't supported. You can do [code]cat index.html | open -f[/code] but that will only open it in a text editor, not a web browser. To open arbitrary html in a web browser you will need to write it to a file.


All times are GMT -8. The time now is 11:50 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.