Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run the system commands in javascript?

Tags:

javascript

I need to list all the files in the javascript such as "ls"??

like image 752
Ambika Avatar asked Mar 16 '11 06:03

Ambika


People also ask

How do I run a system command in JavaScript?

js can run shell commands by using the standard child_process module. If we use the exec() function, our command will run and its output will be available to us in a callback. If we use the spawn() module, its output will be available via event listeners.

Can JavaScript Run command line?

There are JavaScript libraries specially designed to build command-line interfaces. Yes, you can run JavaScript in your terminal. Now, when you enter a command into your terminal, there are generally options, also called switches or flags, that you can use to modify how the command runs.

How do I run a node JS command?

The usual way to run a Node. js program is to run the globally available node command (once you install Node. js) and pass the name of the file you want to execute. While running the command, make sure you are in the same directory which contains the app.


1 Answers

You can't run system commands on the client with JS since it works inside a browser sandbox. You'd need to use some other client side tech like Flash, ActiveX or maybe Applets

like image 178
JohnP Avatar answered Sep 24 '22 10:09

JohnP