express - How to respond to a command line promt with node.js -


How do I respond to command line prompts with node.js? For example, if I do process.stdin.write ('sudo ls'); The command line will prompt for a password

In addition to this, how do I know that when process.stdin.write ('npm install') is something like this Has been completed?

I want to use it to edit this file (required for phasing my app), deploying on my server, and changing those files (ultimately necessary to deploy the output ).

Any help can be rock!

You would like to use this to write the command on stdin Instead.

  var sys = require ('sys'), exec =' ('child_process'). Exec; // execute 'sudo ls' command with a callback function exec ('sudo ls', function (error, stdout, stderr) {if (error!)} // print output sys.puts (stdout);} and { // handle error}}); To set up   

npm you may be better with which you can attach an event listener to run the attachment, you can do the following :

  var spawn = is required ('child_process'). Eggs; // run the 'install' argument with the 'NPM' command run npmInstall var npmInstall = spawn ('npm', ['install'], {cwd: process.cwd (), stdio: ' Inherit ')); // Listen to 'Extit' event // which proceeds from npmInstall.on ('Exit', Function (Code, Signal) (if (code === 0) {// Process successfully completed} And {/ handle error}});    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -