Using Chrome Native Messaging sample app as a template am able make a system call to bash
os.system("<bash command>")
The requirement is to return a base64
string from the python script
os.system("<bash command that returns a base64 string>")
which can verify returns expected result at terminal
.
However, when adjust the code at native-messaging-example-host
at lines 97-98
to
dataurl = os.system("<bash command that returns a base64 string>")
text = '{"text": "' + dataurl + '"}'
the application window closes and
Failed to connect: Error when communicating with the native messaging host.
is printed at the applications' HTML page.
When using the original code
text = '{"text": "' + self.messageContent.get() + '"}'
and sending the base64
string corresponding to the output that the bash
command outputs to the python host, the base64
is sent back to the client. The length of the tested base64
string is 43304
, less than the 1 MB maximum size of messages sent from the host.
Why is the application throwing an error and not sending the base64
string from the python host to the Chromium client?
subprocess
forsupprocess
though the string is not sent to client. The string sent to host is echoed. – Mcmahon