This is my first SE question. Usually I can find an answer to anything fairly easily through this great website, but unfortunately on this occasion I can't find anything on what I am looking for, either here or elsewhere. Let me explain the problem:
I have written a C++ program to do some numerical computations. It takes command line arguments and writes to stdout and works fine on my system running OSX.
I want to host this online for my peers to try it out more easily, and so I wrote some Node.js and Express code to take an input from a form and give that as a command line argument to the executable. I then execute the binary called 'factoriser' in the following way:
const exec = require('child_process').exec;
app.post('/', function (req, res) {
var input = req.body.numberinput; //Number entered on the webpage
const child = exec('./numericcomp ' + input, {timeout: 20000}, function(error, stdout, stderr) {
//Code here writes stdout to the page
}
}
The above works perfectly on my local machine but when I deploy it to Heroku and then try an input (here I tried 2131) I get an error of:
Error: Command failed: ./numericcomp 2131 ./numericcomp: 3: ./numericcomp: Syntax error: word unexpected (expecting ")")
that is given to the callback in exec.
So I really don't know what to do, the issue is that Heroku just isn't running the executable properly. I am not particularly knowledgable about how Heroku works, I have read through info on buildpacks etc. but it seems a very complicated process just to execute a binary. Is it because I only have one dyno and it can't run the child process?
I would be very grateful if someone could point me in the right direction here, it seems I have done all the hard work but can't get over the final hurdle.
See Question&Answers more detail:os