0

I was executing NodeJS files in terminal like, node filename.js but I need to execute this command from JavaScript/jQuery i.e. from html page itself. Is it possible? How?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • You can't execute system commands in browser. – Ram Dec 30 '15 at 09:57
  • you may be able to achieve something with a browser extension, but then it's browser specific and good luck doing anything with internet exploder at all – Jaromanda X Dec 30 '15 at 09:59
  • 6
    The question is, why do you want to do this? What are you trying to accomplish? – Roope Dec 30 '15 at 10:01
  • this is impossible because of security reasons. If you need to execute system commands, consider to write own standalone client. – Oleksandr Papchenko Dec 30 '15 at 10:08
  • I tried with batch files, and in button click(in HTML page) i am triggering that batch file, but the batch file is not getting executed, instead its content get displayed in new tab. I am using IOS X. Is it possible to make execute that batch file with a button click? – Lalith Kumar Dec 31 '15 at 06:13
  • On the backend expose some API - than call it from frontend via AJAX / websockets – Krzysztof Safjanowski Jan 01 '16 at 10:55

1 Answers1

0

As far as i am aware about it, javascript can not interact with client machine from browser, and it should not be able to do it for security reasons.

But you should be able to run system commands on server. The idea is that you make GET to some nodejs resource which executes system commands on serverside.

I think this should be useful execute-a-command-line-binary-with-node-js

(I think that such approach exposes server and everything on it to a security risk. Access to the server must be heavily monitored!!!)

Community
  • 1
  • 1
Tornike Shavishvili
  • 1,244
  • 4
  • 16
  • 35