简体   繁体   English

用JavaScript执行Shell命令

[英]Executing shell commands with javascript

I know it's not possible to execute shell commands on the clients browser via js.But I was wondering if it's possible if in the client side is not a browser instead an application that just fetchs webpages? 我知道不可能通过js在客户端浏览器上执行shell命令,但我想知道是否可能在客户端中不是浏览器而是仅获取网页的应用程序? thanks for your time guys! 谢谢您的时间!

The best would be to use a nodejs app 最好的方法是使用Node.js应用

Node can be used to run javascript for everything in your computer, so, answering your question, you could, say, make an aplication that fetches webpages and run selected commands in the code that would be rejected by the browser. Node可以用于为您计算机中的所有内容运行javascript,因此,回答您的问题,您可以做一个应用程序,以获取网页并以将被浏览器拒绝的代码运行选定的命令。

But, if actually your goal is to just use javascript like a general use interpreted language (like say, python), you can just use js with node normally (ie, make your foo.js file and run from command line node ./foo.js 但是,如果实际上您的目标是像一般使用的解释性语言(如python)一样使用javascript,则可以仅将js与node一起使用(即,制作foo.js文件并从命令行node ./foo.js运行)。 node ./foo.js

You can also use it as a server for web applications 您也可以将其用作Web应用程序的服务器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM