开发者

In xul, how to retrieve an environment variable?

I have an environment called $REP, how can I access the value of this variable using Xulrunner in a Linux environment?

--udpate

attempting with nslEnvironment:

var env = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
dump("bash=" + env.exists("BASH") + '\n');
dump("bash=" + env.exists("$BASH") + '\n');

the output was:

bash=false
b开发者_Python百科ash=false

as you imagine, it should output "/bin/bash" as it does in the terminal. I also tried using get to see if it was just the exists method wrong, but it returned empty.

What can be wrong here?


Use nsIEnvironment to read (and set) environment variables.


Have a look at Setting an environment variable in javascript (which you happened to edit, randomly!).

I very much doubt you'll be able to read these variables from a browser environment though.

edit:

var oShell = WScript.CreateObject("WScript.Shell");
var oSysEnv = oShell.Environment("SYSTEM");
WScript.Echo (oSysEnv("PATH"));

perhaps?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜