twitter - Error: spawn sh ENOENT Node.js -


i trying trigger pifm on raspberry pi tweets specific twitter account using node.js. when run twitpifm.js on command line:

node twitpifm.js 

i following error:

events.js:141       throw er; // unhandled 'error' event       ^  error: spawn sh enoent     @ exports._errnoexception (util.js:874:11)     @ process.childprocess._handle.onexit (internal/child_process.js:178:32)     @ onerrornt (internal/child_process.js:344:16)     @ dontcallback2 (node.js:439:9)     @ process._tickcallback (node.js:353:17)     @ function.module.runmain (module.js:469:11)     @ startup (node.js:134:18)     @ node.js:961:3 

i using version of pifm on pi2

https://github.com/asmello/fm_transmitter

i have written script (test.sh) start pifm command line without parameters

 #!/bin/bash     /home/pi/pifm/fm_transmitter/bin/release/fm_transmitter music.wav 103.50 

i aware need need use child_process within node.js activate shell script having trouble it;

first invoke child process with:

var spawn = require('child_process').spawn // child process.spawn  

i try trigger shell following:

function thistweet(){      spawn('sh', ['test.sh'], {  // shell script want run.     cwd:' /home/pi/desktop/twitter', // current working directory twitpifm.js file      env: object.assign({}, process.env, { path: process.env.path + '/home/pi/pifm/fm_transmitter' }) //this sets path test.sh     }) 

any suggestions great!

ok..i got solution seems working using . execfile here:

https://nodejs.org/api/child_process.html#child_process_child_process_execfile_file_args_options_callback

this code worked:

const execfile = require('child_process').execfile; const child = execfile('sh', ['/home/pi/desktop/twitter/test'], (error, stdout, stderr) => {   if (error) {     throw error;   }   console.log(stdout); }); }   

this lets me execute shell script node.js


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -