javascript - How to execute a command in a Firefox Add-On? -
i quite new writing firefox add-ons, still, got point patched working extension, except core of it.
at point in code, need execute system-command on file. i've found snipped on web , tried adapt it, without luck. xpi/components/script.js
:
var cmd = '/usr/bin/somecommand' var args = ['-option', 'value', f.path ]; var execfile = components.classes["@mozilla.org/file/local;1"].createinstance(components.interfaces.nsilocalfile); var process = components.classes["@mozilla.org/process/util;1"].createinstance(components.interfaces.nsiprocess); execfile.initwithpath(cmd); if (execfile.exists()) { process.init(execfile); process.run(false, args, args.length); }
can tell me what's wrong here? i've assembled command , i've got filename can't firefox execute code snippet.
is execfile
, initwithpath
, createinstance
, etc. stuff needed?? want execute command in cli:
$ somecommand -option value filename
works fine me cmd
, args
changed to:
var cmd = '/usr/bin/say'; var args = ['hello', 'world' ];
as neil says, need more info troubleshooting. enable error console , check if there messages there.
Comments
Post a Comment