From 7b3591a206b703f08642581e54a2fcf348765b4a Mon Sep 17 00:00:00 2001 From: Gerrit Linnemann Date: Sun, 15 Nov 2015 22:19:54 +0100 Subject: [PATCH] spawn to exec --- kitchenradio/app/radio.js | 13 +++++++++++-- kitchenradio/bin/action.sh | 2 +- kitchenradio/bin/start_radio.sh | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/kitchenradio/app/radio.js b/kitchenradio/app/radio.js index affb6ba..6ef2659 100644 --- a/kitchenradio/app/radio.js +++ b/kitchenradio/app/radio.js @@ -101,10 +101,19 @@ exports.play = function(idx) { Log.error(e); }*/ - var Child = spawn( + /*var Child = spawn( App.get('tools_root')+'action.sh', ['play'] - ); + );*/ + + child = exec(App.get('tools_root')+'action.sh play', + function (error, stdout, stderr) { + console.log('stdout: ' + stdout); + console.log('stderr: ' + stderr); + if (error !== null) { + console.log('exec error: ' + error); + } + }); // listen for any response from the child Child.stdout.on('data', function(chunk) { diff --git a/kitchenradio/bin/action.sh b/kitchenradio/bin/action.sh index 464de6a..364d5e0 100755 --- a/kitchenradio/bin/action.sh +++ b/kitchenradio/bin/action.sh @@ -13,6 +13,6 @@ MY_PATH="$(pwd)" echo "Action: $1" case $1 in - 1) echo "play" ;; + "play") sh $MY_PATH/bin/start_radio.sh ;; *) echo "INVALID ACTION!" ;; esac \ No newline at end of file diff --git a/kitchenradio/bin/start_radio.sh b/kitchenradio/bin/start_radio.sh index c26442c..9b4d264 100755 --- a/kitchenradio/bin/start_radio.sh +++ b/kitchenradio/bin/start_radio.sh @@ -19,4 +19,4 @@ echo echo "${BGre}Start playing $stream2play ...${RCol}" echo -#mplayer -slave -quiet $stream2play \ No newline at end of file +mplayer -slave -quiet $stream2play \ No newline at end of file