# How to make Firefox 9 read stdin?

An earlier question got several nice answers involving stdin, none of which work in Firefox 9.0.1 (Edit: because I didn't read that you had to start a new Firefox process to make them work (thanks @manatwork):

• echo '<h1>hello, world</h1>' | firefox /dev/fd/0 results in a new tab with the URL file:///dev/null and no text.
• cat | firefox /dev/fd/0 results in a new tab with the URL file:///dev/null and no text. After typing a single line of text and pressing Enter it terminates and still doesn't show anything in the new tab.
• firefox <( echo '<h1>hello, world</h1>' ) opens up a new tab with my profile folder, of all things.

Is there any way to make this work in Firefox 9.0.1 or newer?

As to the reason behind, it would be nice to be able to generate markup which is only stored in memory (barring swapping), and guarantee that there is no left-overs even in case of a power cut.

• Those work in Firekox 9.0.1 too, with the same restriction as earlier: “If your firefox command is actually starting Firefox instead of talking with an already-running Firefox instance”, as mentioned there by Jander. – manatwork Feb 2 '12 at 12:38

I found a program called bcat written in ruby. Couple of examples can be accessed via this link.

• This is absolutely terrific! On *buntu it is included in the standard repositories sudo aptitude install ruby-bcat. – dotancohen Nov 24 '14 at 8:16

Followin @userunknown suggestion, in case your /tmp is not a tmpfs type filesystem, then you can use /dev/shm or create your own tmpfs filesystem (both are held in memory):

/mnt/tmp && mount -t tmpfs none /mnt/tmp


As to the reason behind, it would be nice to be able to generate markup which is only stored in memory (barring swapping), and guarantee that there is no left-overs even in case of a power cut.

I don't know for other Unixes, but on Linux, /tmp is deleted on every startup/shutdown. So

echo "<html><head><title> FooTemp </title></head></html>" \
> /tmp/foo.html && firefox /tmp/foo.html && rm /tmp/foo.html


works fine for me.

More convenient maybe: Delete the file immediately after opening it in Firefox, I tested it:

echo "<html><head><title> FooTemp </title></head></html>" > \
/tmp/f3.html && (firefox /tmp/f3.html & sleep 3 ; rm /tmp/f3.html)


Give it some seconds to render it, and then delete it. Works like a charm for me. No /tmp/f3.html to be seen with ls /tmp/*html after 3 seconds, but visible in the browser.

• That still leaves a file on the HD while Firefox is running and even afterwards if the process is killed before rm, which was the point of the question. – l0b0 Feb 2 '12 at 15:06
• @l0b0: I updated my answer; it now contains a solution where the temporary file is deleted after 3 seconds. – user unknown Feb 2 '12 at 18:32

Firefox 9, and greater, support Data URI scheme. Any HTML will need a data:text/html, prefix.

shell ~> firefox -new-tab 'data:text/html,<html><body><h1>Hello World</h1></body></html>'


Not quite stdin, but it should work

shell ~> firefox -new-tab "data:text/html,"cat myfile.txt

• The first example did not work on Firefox 14.0.1 - It simply opened a new window (not tab) with my default home page. – l0b0 Aug 6 '12 at 8:45