How to execute an executable from Linux with javascript

送分小仙女□ 提交于 2019-12-24 16:01:29

问题


I'm making an application for D-bus in javascript. I need to call an executable from the javascript code and I know that it's possible to do it in Windows like this

var activeXObj = new ActiveXObject("Shell.Application"); 
activeXObj.ShellExecute("C:\\WINDOWS\\NOTEPAD.EXE", "", "", "open", "1");

But...how to do the same in Linux??

Thanks a lot

P.S: Is not for a browser =)


回答1:


Install node.js (depending on your distro, sudo apt-get install nodejs) and use the ChildProcess module to execute the program.

Or, get Rhino and use the runCommand command;



来源:https://stackoverflow.com/questions/16607782/how-to-execute-an-executable-from-linux-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!