1

I am trying to run some command on the client system through server. I know server has lots of security issues while executing server commands, is there any way to run command form browser.

I have following commands in nodejs but, i need this to run form the browser in clients system.

same as in this question but form html page. node.js shell command execution

function run_cmd(cmd, args, callBack ) {
   var spawn = require('child_process').spawn;
   var child = spawn(cmd, args);
   var resp = "";      
   child.stdout.on('data', function (buffer) { resp += buffer.toString() });
   child.stdout.on('end', function() { callBack (resp) });
} 

Usage:

run_cmd( "ls", ["-l"], function(text) { console.log (text) });

1 Answer 1

2

No, you may not execute arbitrary shell/console commands through a browser.

The security implications for this would be gigantic. You wouldn't want someone to execute:

run_cmd( "rm", ["-rf *"], function(text) { console.log ("lol") });

Through your browser. Not even if you could explicitly trust it.

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

3 Comments

Isn't there any way to accomplish such task?
Is there any way to open a program that is installed on client machine from HTML page through javascript. This will also sove my problem.
Not through Javascript, no. If you have control of that client machine, you could write a piece of software and use protocol handler to launch that software. It can then redirect the request to the console on behalf of the user.

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.