Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to pass var to the shell script

Status
Not open for further replies.

JPSeo

Systems Engineer
Sep 3, 2020
6
US
Hello:

Newbie question here: Trying to pass a var to the child_process shell command.
Not sure what should be proper syntax. Thnx

Code:
const exec = require('child_process').exec

app.listen(port);
console.log('Server started! At [URL unfurl="true"]http://10.130.16.65:'[/URL] + port);

function execute(command) {

exec(command, (err, stdout, stderr) => {
process.stdout.write(stdout)
})
}

// [URL unfurl="true"]http://10.130.16.65:8080/api/qmgrs?id=root&qmgr=TEST[/URL]

app.get('/api/qmgrs', function(req, res) {

  var user_id = req.param('id');
  var QMGR = req.param('qmgr');

 exec("sudo su mqm -c 'echo \"dis qmgr\" | runmqsc QMGR'", function(err, stdout, stderr) {
    if (err) {
      res.writeHead(500, {"Content-Type": "text/plain"});
      res.end(stderr);
    }
    else {
      res.writeHead(200,{"Content-Type": "text/plain"});
      res.end(stdout);
    }
  });
});

getting the following errors:
Code:
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
stty: standard input: Inappropriate ioctl for device
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top