Running a childProcess as shell script with node.js server

0 votes

I'm running a shell script on my node.js server. Now, one childProcess works perfectly:
childProcess.exec('ls /media/external/', movieCallback); 

But the other process just won't work:
childProcess.exec('~/./play.sh /media/external/' + req.params.movie, function() {}); 

Here's the error I get:
/bin/sh: 1: /root/./play.sh: not found 

Also, running the script in terminal, it works just fine. I've double-checked that chmod +x is set.
Any clues on what could be going wrong?
Do tell! Thanks in advance.

Aug 14, 2018 in IoT (Internet of Things) by Bharani
• 4,550 points
39 views

1 answer to this question.

0 votes

Here's what I think, you could pass the arguments error, stdout and stderr to the exec function callback. Then, try identifying the problem by spitting them out to the console so that it's easy to spot it out:

exec('~/./play.sh /media/external/' + req.params.movie,
  function (error, stdout, stderr) {
    console.log('stdout: ' + stdout);
    console.log('stderr: ' + stderr);
    if (error !== null) {
      console.log('exec error: ' + error);
    }
});

Hope this helps! :)

answered Aug 14, 2018 by DataKing99
• 8,100 points

Related Questions In IoT (Internet of Things)

0 votes
1 answer

Connect to external server through Socket.IO from Node.js

I think the server you're connecting to ...READ MORE

answered Nov 21, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
932 views
0 votes
1 answer

Display time in a Windows Core IoT app with a clock!

It is possible, but you should understand ...READ MORE

answered Jul 9, 2018 in IoT (Internet of Things) by nirvana
• 3,060 points
90 views
0 votes
1 answer

Using FIWARE to start Cygnus as a Service in IoT Solution

Cygnus is supposed to create /var/run/cygnus/ when started. You ...READ MORE

answered Aug 13, 2018 in IoT (Internet of Things) by anonymous2
• 4,260 points
70 views
0 votes
1 answer
0 votes
1 answer

How to send Bitcoins with node.js?

This website https://blockr.io/tx/push will successfully do the bitcoin transaction. You ...READ MORE

answered Jul 20, 2018 in Blockchain by Christine
• 15,790 points
314 views
0 votes
1 answer

How to read the ETH value and other token values from an account?

You can do this eth.accounts shows you all known ...READ MORE

answered Oct 22, 2018 in Blockchain by Omkar
• 67,290 points
26 views
0 votes
1 answer
0 votes
1 answer