I am developing a Firefox extension and would like to call an external binary from it. It would be great if I could use standard input/output to communicate, so I am looking for the best (and simplest) possible option. This is what I learnt so far:
As I understood, this functionality is implemented in Enigmail, which uses command line gpg tool. Does anyone have some specifics on that?
From all I know, Enigmail uses a binary XPCOM component to achieve this, usually this isn't a viable solution for an extension. And communicating with another process via standard input/output isn't part of the Gecko platform. So I think that you have three options:
CreateProcess
and specify handles for the standard input/output in the lpStartupInfo
parameter. Of course you would also have to use OS functions to work with the streams. This quickly gets very hairy if you need to support multiple operating systems."/bin/sh"
instead of env.get("COMSPEC")
. You could write the input data for your command line application into in.txt
and then run the command foo < in.txt > out.txt
- the output will be in out.txt
when the command is done. Obviously, this will not work if you need to interact with the application while it is running.localhost
. Or you turn it into a dynamic library (.dll
on windows, .so
on Unix-like systems) and communicate with it via js-ctypes.