Merc Merc - 3 months ago 16
Bash Question

Run interactive script with node, let user interact with it, go back to node script when done

I would like to run a program from my node app and let users interact with it.
The purpose is a server management node script. When I type

naps dbadmin gigsnet
, I want node to run
putting all of the right parameters in (user, database, etc.).

This is NOT a duplicate of this, since I want the user to actually freely interact with the mongo shell -- a bit like it happens when you run a program from a bash script.

Am I missing something totally simple?

Answer Source

I ended up doing this:

var db = 'someDatabase'
var user = 'someUser'
var pass = 'somePassword'
spawn('mongo', ['-u', user, '-p', password, '--authenticationDatabase', 'admin', db ], {stdio: 'inherit', shell: true})

This worked well for me. It was a bit of trial-end-error to make it work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download