# Exec node error when running terminal commands

**URL:** <https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839>\
**Category:** General\
**Created:** [26 July 2018 18:21 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839 "2018-07-26T18:21:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [26 July 2018 18:21 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/1 "2018-07-26T18:21:18Z")

</div>

![utube%20error%20nodered](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/29e61cd6380a9dcec5ba0c96d8d9b66624210169.jpg)

i have error when using exec node to run commands . It works on the terminal. It streams video to youtube.  
Can anyone help me how to run commands from nodered?

Thank you

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [26 July 2018 18:34 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/2 "2018-07-26T18:34:09Z")

</div>

You have the `append msg.payload` option selected. This means the command it is running will have whatever msg.payload is to added at the end. This probably isn't what you want and could be causing the issue.

Have you got all three outputs wired to debug nodes so you can see any error messages it returns?

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [26 July 2018 18:50 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/3 "2018-07-26T18:50:20Z")

</div>

I still have error. It works a while on the PC screen and disconnected before gng to youtube live stream.  
Debug node msg,

Command failed: raspivid -o - -t 0 -w 1280 -h 720 -fps 30 -b 6000000 -g 50 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm\_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/ ......

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 July 2018 19:25 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/4 "2018-07-26T19:25:53Z")

</div>

Is it trying to preview the video also ? I think raspivid has an option to turn that off

-n. I think

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [26 July 2018 21:03 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/5 "2018-07-26T21:03:03Z")

</div>

Try a different command to see if it is the command you are using. If it is the command you are using, try it in a terminal and see if it works...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 July 2018 09:46 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/6 "2018-07-27T09:46:56Z")

</div>

> [@mshaz](#):
>
> It works on the terminal

When you run it on the terminal make sure it does not display anything other than text in the terminal.

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [27 July 2018 20:54 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/7 "2018-07-27T20:54:14Z")

</div>

I tried all the suggested still not working. It works on terminal bt not on nodered exec node. Is there any other alternatives?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [27 July 2018 21:23 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/8 "2018-07-27T21:23:13Z")

</div>

what are you actually trying to achieve?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 July 2018 21:46 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/9 "2018-07-27T21:46:38Z")

</div>

> [@mshaz](#):
>
> I tried all the suggested still not working. It works on terminal bt not on nodered exec node. Is there any other alternatives?

Are you running the command in the terminal in the same computer that is running node-red (not the one running the browser, if they are different).

If you are then simplify the command till it does not error, then add to it till you find what it is that fails.

Also check all outputs from the exec node to see if there is any additional information.

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [28 July 2018 06:02 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/10 "2018-07-28T06:02:35Z")

</div>

raspivid -o - -t 0 -w 1280 -h 720 -fps 30 -b 6000000 -g 50 | ffmpeg -re -ar 44100 -ac 2 -acodec pcm\_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv rtmp://a.rtmp.youtube.com/live2/3ssu-pv0e-510f-atr4  
[https://www.youtube.com/embed/live\_stream?channel=CHANNEL\_ID](https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID)

this is the command. i think it is stuck with error while trying to stream live to youtube. I separated the command rtmp://a.rtmp.youtube.com/live2/3ssu-pv0e-510f-atr4  
[https://www.youtube.com/embed/live\_stream?channel=CHANNEL\_ID](https://www.youtube.com/embed/live_stream?channel=CHANNEL_ID) and put in extra input parameter. There was no error on the video bt it dosen't stream to youtube.

Cn i put the command in python code and run the file name from exec node? I m nt sure how to write python code. Can anyone help me on this?

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [28 July 2018 06:16 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/11 "2018-07-28T06:16:50Z")

</div>

you still haven’t said what you are trying to achieve. What is the aim of the flow you are writing? You want to stream a video from youtube into Node-RED, once you have got it there what do you want to do with it?

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [28 July 2018 07:45 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/12 "2018-07-28T07:45:50Z")

</div>

I m streaming video from camera to youtube. This is the tutorial i followed [https://www.youtube.com/watch?v=pIV5HVeP9\_o](https://www.youtube.com/watch?v=pIV5HVeP9_o)

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 July 2018 08:41 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/13 "2018-07-28T08:41:58Z")

</div>

Did you try -n as I suggested ?

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [28 July 2018 09:01 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/14 "2018-07-28T09:01:50Z")

</div>

yes didnt work either.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [28 July 2018 09:24 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/15 "2018-07-28T09:24:00Z")

</div>

Have you checked all the outputs from the exec node, it would be useful to be able to see the full error message.

Also please export the config of the exec node and paste it here so we can see exactly what you are trying, and can try it ourselves.

Colin

---

<div class="post-metadata">

**Author:** ![asandford](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@asandford](https://discourse.nodered.org/u/asandford)\
**Post date:** [31 July 2018 00:10 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/16 "2018-07-31T00:10:17Z")

</div>

Wrap the command in a bash script.

Run the script from the command line to confirm it works.

Try in the exec node

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [1 August 2018 20:33 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/17 "2018-08-01T20:33:49Z")

</div>

Its working now thank you guys. I used bash script.

---

<div class="post-metadata">

**Author:** ![mshaz](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mshaz/32/2294_2.png) [@mshaz](https://discourse.nodered.org/u/mshaz)\
**Post date:** [1 August 2018 21:03 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/18 "2018-08-01T21:03:39Z")

</div>

How do i kill it. I did a fuction node msg.kill = true; it doesnt work.

[{"id":"a93dd8b3.041ad8","type":"debug","z":"6c0fc2e7.5fcb6c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":720,"y":3740,"wires":[]},{"id":"a95cb02.0c7195","type":"exec","z":"6c0fc2e7.5fcb6c","command":"/home/pi/camyoutube.sh","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"","x":430,"y":3660,"wires":[["a93dd8b3.041ad8"],[],[]]},{"id":"568e7918.52ef68","type":"inject","z":"6c0fc2e7.5fcb6c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":120,"y":3660,"wires":[["a95cb02.0c7195"]]},{"id":"53f1c37c.cb2abc","type":"function","z":"6c0fc2e7.5fcb6c","name":"","func":"msg.kill = true;\nreturn msg;","outputs":1,"noerr":0,"x":260,"y":3840,"wires":[["a95cb02.0c7195"]]},{"id":"7cc4f0f6.0e30e","type":"inject","z":"6c0fc2e7.5fcb6c","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":100,"y":3780,"wires":[["53f1c37c.cb2abc"]]}]

---

<div class="post-metadata">

**Author:** ![asandford](https://avatars.discourse-cdn.com/v4/letter/a/eb8c5e/32.png) [@asandford](https://discourse.nodered.org/u/asandford)\
**Post date:** [1 August 2018 21:59 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/19 "2018-08-01T21:59:06Z")

</div>

write a bash script to pkill your other script

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [1 August 2018 23:13 UTC](https://discourse.nodered.org/t/exec-node-error-when-running-terminal-commands/1839/20 "2018-08-01T23:13:49Z")

</div>

If this is a long running script you may want to look at the node-red-node-daemon node as that can pass msg s into stdin of the process and listens to stdout and stderr (But of course assumes your script can accept input while running)

For exec You can tell msg.kill what type of signal to use to stop the process so you should be able to find one that kills it properly.
