1

I need to use some of the Linux commands in the JavaScript. Is it possible to do that?? If yes what's the syntax for the same??

3
  • 5
    Are you talking about browser Javascript or something like node.js or rhino. If you mean browser JS then you can't. If you mean node.js you probably can do this. Commented Mar 7, 2011 at 16:47
  • Please be more specific. You want JS on your pages to access the file systems of your users? That simply is not possible, by design. Commented Mar 8, 2011 at 12:01
  • You should definitly find another way to achieve what you need, just because it's like opening your server to the world. At worst you could use ajax calls or SSI or cgi if you need to establish a client-server kind of communication. Commented Mar 9, 2011 at 2:11

2 Answers 2

1

In Node.js you can spawn child processes (amongst others: run a linux command) with a child_process.

Sign up to request clarification or add additional context in comments.

Comments

0

It's not possible. You can't access the user's (file)system with Javascript because that would be a pretty huge security leak.

2 Comments

Not true per sé. Off course, Javascript running in the Browsers VM cannot get outside its VM (and access a filesystem), but something like Node.JS can access and run unix commands just fine.
But node.js does not run on clients

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.