echo '<h1>hello, world</h1>' | firefox
cat index.html | firefox
These commands don't work.
If firefox can read stdin, I can send html to firefox via pipe.
Is it possible to make firefox read stdin?
These commands don't work. |
|||||||||
|
|
The short answer is, you're better off writing a temporary file and opening that. Getting pipes to work properly is more complicated and probably won't give you any extra advantages. That said, here's what I've found. If your
Which tells Firefox explicitly to read its standard input, which is where the pipe is putting its data. But if Firefox is already running, the Furthermore, when reading from a pipe, Firefox buffers things pretty heavily, so it's not going to update the page each time you give it a new line of HTML, if that's what you're going for. Try closing Firefox and running:
(N.B. you do actually need the So best is probably:
|
|||
|
|
|
You can use process substitution:
|
||||
|
|
|
Look what searching for 'browser stdin' turned up!, a nice little shell script:
If you save this in |
|||
|
|
|
I wrote a python script to write stdin to a temporary file and then open the temporary file with Firefox.
|
|||
|
|
|
I found this: bcat -- pipe to browser utility ... to install on Ubuntu Natty, I did:
I thought it works with its own browser - but running the above opened a new tab in an already running Firefox, pointing at a localhost address
... a tab will again open, but Firefox will keep showing the loading icon (and apparently would update the page when syslog updates). The EDIT: As I needed something like this badly (mostly to view HTML tables with data generated on the fly (and my Firefox is getting really slow to be useful with Basically, with the downloaded script (and dependencies) you can alias it in a
... and in one terminal (after aliasing),
... as shown below: Don't forget the Basically, the problem here is to solve:
As such, the same could be implemented in, say, Perl with Gtk bindings and WebKit (or other browser component). I wonder, though, if the XUL framework by Mozilla could be used to implement the same functionality - I guess in that case, one would work with the Firefox browser component. |
||||
|
|