用firefox sdk运行一个linux命令 [英] run a linux command with firefox sdk

查看:130
本文介绍了用firefox sdk运行一个linux命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用firefox sdk运行一个Linux命令。我已经搜索了这个,但是所有的例子都描述了如何在windows中运行一个可执行文件。我需要运行一个Linux命令。

解决方案

只要使用 nsIProcess ,这样:

  const {Cc,Ci} = require(chrome); 

//为可执行文件创建一个nsIFile
var file = Cc [@ mozilla.org/file/local;1\"].createInstance(Ci.nsIFile);
file.initWithPath(/ usr / bin / du);

//创建一个nsIProcess
var process = Cc [@ mozilla.org/process/util;1\"].createInstance(Ci.nsIProcess);
process.init(file);

//运行这个过程。
//如果第一个参数为真,调用线程将被阻塞,直到
//被调用进程终止。
//第二个和第三个参数用于将命令行参数
//传递给进程。
var args = [-h];
process.run(false,args,args.length);


I wanna run a Linux command with firefox sdk.

already I searched about that , but all example describe how to run an executable file in windows. I need to run a Linux command.

解决方案

Just use nsIProcess, this way:

const {Cc, Ci} = require("chrome");

// create an nsIFile for the executable
var file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsIFile);
file.initWithPath("/usr/bin/du");

// create an nsIProcess
var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
process.init(file);

// Run the process.
// If first param is true, calling thread will be blocked until
// called process terminates.
// Second and third params are used to pass command-line arguments
// to the process.
var args = ["-h"];
process.run(false, args, args.length);

这篇关于用firefox sdk运行一个linux命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆