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,660 points
756 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,250 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,130 points
15,262 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 10, 2018 in IoT (Internet of Things) by nirvana
• 3,130 points
1,554 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,240 points
939 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,240 points
768 views
0 votes
1 answer

How to send Bitcoins with node.js?

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

answered Jul 20, 2018 in Blockchain by Christine
• 15,790 points
3,402 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,220 points
852 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 11, 2019 in IoT (Internet of Things) by DataKing99
• 8,250 points
2,097 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP