Search code examples
node.jsshelljs

NodeJS Execute a bash script that prompts for keyboard input


I am trying to execute an external bash script from nodejs.

The script when executed from terminal, prompts for input, such as a password.

When executing from nodejs, i can not get it to pause to read the input.

Can not find any good info online on this.

Is this not possible?

var shelljs = require( 'shelljs' )

var returns     = shelljs.exec("passwd", {shell: '/bin/bash'}, {stdio:'inherit'});

passwd: conversation failure


Solution

  •   shelljs.exec("exec </dev/tty\n passwd", ... )
    
      seems to work. found by accident. 
    

    Not sure if this is the best way though.

    Not very solid i think.