/    Sign up×
Community /Pin to ProfileBookmark

Another cjhild_process.exec issue with complex shell command

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 !!

[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(/[rn|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> `

to post a comment

2 Comments(s)

Copy linkTweet thisAlerts:
@JPSeoauthorSep 23.2020 — Sorry about the messy post..

Tried to wrap in code tags but not sure what happened .. :-(
Copy linkTweet thisAlerts:
@SempervivumSep 23.2020 — Code tags will work reliably: `your code here`. I edited your posting accordingly.
×

Success!

Help @JPSeo spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.25,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...