javascriptbashfirefoxfirefox-addonfirefox-addon-sdk

Is it possible to run a bash script from Firefox? (Using Firefox add-on SDK)


I'm trying to create a Firefox add-on that can automatically run bash commands when you click on a specific button. (Client Side always)

For now I managed how to execute simple commands like ls using:

var child_process = require("sdk/system/child_process");

var ls = child_process.spawn('/bin/ls', ['-lh', '/usr']);

My question is, can I run bash scripts? (.sh files)

for example:

#!/bin/bash
STRING="HELLO WORLD!!!"
echo $STRING

Solution

  • It is! Pretty easy.

    var bash = child_process.spawn('/bin/sh', ['pathtobashscript']);