Hello:
Trying to run the following code but the arrays is not getting populated.
bash.cmd_4 works but bash.cmd_1 returns nothing.
I am guessing I am missing some delimiters.
Pls advise, Thank you !!
Trying to run the following code but the arrays is not getting populated.
bash.cmd_4 works but bash.cmd_1 returns nothing.
I am guessing I am missing some delimiters.
Pls advise, Thank you !!
Code:
var array_id = new Array();
app.get('/qmgrs', function(req, res) {
var QMGR = req.param('qmgr');
//var QMGR = req.query.qmgr;
var bash =
{
cmd_1: `su mqm -c 'amqoamd -m ${QMGR} -s | egrep -iv \"system|mqm\"' |grep \"-n\"| awk \"{print $9}\"| sort -u`,
cmd_4: `su mqm -c dspmq | grep ${QMGR}`
}
cp.exec(bash.cmd_1, function(err, stdout, stderr) {
if (err) {
console.log(stderr)
}
else {
array_id = stdout.split(/[\r\n|\n|\r]/).filter(String);
console.log(array_id);
//res.writeHead(200,{"Content-Type": "text/plain"});
//res.end(stdout);
res.render('users',{array_id: array_id});
}
});
});
Code:
<html>
<head>
<% include('header.ejs') %>
</head>
<body>
<h1>App_ID List</h1>
<h1>============</h1>
<ul>
<% for(var i=0; i<array_id.length; i++){ %>
<!-- <h1><%= array_id[i] %></h1> -->
<h1><a href="/users?app_id=<%= array_id[i] %>"><%= array_id[i] %></a></h1>
<% } %>
</ul>
</body>
</html>