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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple SyntaxError: missing ) after argument list error

Status
Not open for further replies.

JPSeo

Systems Engineer
Sep 3, 2020
6
0
0
US
Heloo Experts:

I am getting the "SyntaxError: missing ) after argument list" error
for the code below:

==========================================
function execute(command) {
const exec = require('child_process').exec

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

execute("sudo su mqm -c 'echo "dis qmgr" | runmqsc TEST'");
============================================

I am not sure how to manage the "" and ''.

Pls advise, Thank you !!



 
Hi

Just escape the literal double quotes inside the string :
JavaScript:
[COLOR=orange]execute[/color][teal]([/teal][i][green]"sudo su mqm -c 'echo [/green][/i][lime][highlight]\[/highlight]"[/lime][i][green]dis qmgr[/green][/i][lime][highlight]\[/highlight]"[/lime][i][green] | runmqsc TEST'"[/green][/i][teal]);[/teal]

Or if Explorer support is not necessary, you could use template string :
JavaScript:
[COLOR=orange]execute[/color][teal]([/teal][i][green][highlight]`[/highlight]sudo su mqm -c 'echo "dis qmgr" | runmqsc TEST'[highlight]`[/highlight][/green][/i][teal]);[/teal]
( See where. )

Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top