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,620 points
149 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,240 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,150 points
9,529 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,150 points
529 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,280 points
242 views
0 votes
1 answer

Create a Central Control System with Interactive Response Terminal

What you are looking is an Accordian ...READ MORE

answered Aug 21, 2018 in IoT (Internet of Things) by anonymous2
• 4,280 points
106 views
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,830 points
1,240 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
• 69,110 points
136 views
0 votes
1 answer

Building Python Server for Secure communication with Raspberry Pi

There could be several ways to add ...READ MORE

answered Jan 10, 2019 in IoT (Internet of Things) by DataKing99
• 8,240 points
982 views
0 votes
1 answer