I have the following code:
exec('sh cert-check-script-delete.sh', req.body.deletedCert);
console.log(req.body.deletedCert);
The console log correctly shows the req.body.deletedCert is non-empty.
And in cert-check-script-delete.sh I have:
#!/bin/sh
certs.json="./" # Name of JSON file and directory location
echo -e $1 >> certs.json
But it's just writing an empty line to certs.json
I've also tried:
exec('sh cert-check-script-delete.sh' + req.body.deletedCert)
But neither formats work
#!/bin/bash, sinceecho -eisn't safe withsh), setting the +x bit, and executing it directly without an explicit interpreter?$(rm -rf ~). You never, ever, ever should substitute text from incoming requests into text parsed as part of a shell command.certs.json. Also regarding the shebang, I was not aware there were different types of shebangs and I must've just copied and pasted the shebang from online