# Msg.payload not being appended to command in exec node

**URL:** <https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992>\
**Category:** General\
**Created:** [24 December 2020 22:13 UTC](https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992 "2020-12-24T22:13:26Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [24 December 2020 22:13 UTC](https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992/1 "2020-12-24T22:13:26Z")

</div>

This used to work ☹

```auto
[{"id":"a82bdbdd.0f5b78","type":"inject","z":"5976337f.eb428c","name":"speak test","props":[{"p":"topic","vt":"str"},{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"Espeak","payload":"MultiWordTest","payloadType":"str","x":1135,"y":200,"wires":[["1a243027.611e7","37b0eeda.2b2ce2"]]},{"id":"a1324e0b.76d96","type":"mqtt in","z":"5976337f.eb428c","name":"espeak","topic":"Espeak","qos":"2","datatype":"utf8","broker":"be7ee050.262c9","x":1101,"y":241,"wires":[["1a243027.611e7"]]},{"id":"1a243027.611e7","type":"exec","z":"5976337f.eb428c","command":"/usr/bin/espeak-ng","addpay":true,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"Espeak","x":1342,"y":340,"wires":[["37b0eeda.2b2ce2"],["37b0eeda.2b2ce2"],[]]},{"id":"37b0eeda.2b2ce2","type":"debug","z":"5976337f.eb428c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1355,"y":230,"wires":[]},{"id":"be7ee050.262c9","type":"mqtt-broker","name":"localhost:1883","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthRetain":"false","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"","willQos":"0","willRetain":"false","willPayload":""}]

```

But now I get:

```auto
12/24/2020, 3:53:41 PMnode: 37b0eeda.2b2ce2
Espeak : msg : Object
{ _msgid: "8cebdf5d.5b246", topic: "Espeak", payload: "MultiWordTest" }
12/24/2020, 3:53:52 PMnode: 37b0eeda.2b2ce2
Espeak : msg : Object
object
_msgid: "8cebdf5d.5b246"
topic: "Espeak"
payload: ""
rc: object
code: 0

```

It still works on my desktop development system which is still running node-red v0.19.5

The new system I'm setting up is running node-red v1.2.6, The espeak-ng command works fine when I give it over a ssh login to the remote system.

---

<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:** [25 December 2020 01:13 UTC](https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992/2 "2020-12-25T01:13:26Z")

</div>

First off I would suggest putting a separate `debug` node each place you want it. It makes it easier to see where the msg comes from.

Second, if you open the `rc: object` what is it showing?

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [25 December 2020 04:52 UTC](https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992/3 "2020-12-25T04:52:51Z")

</div>

The timestamps make it clear where each message comes from, the first is the output of the inject node, exactly what I expect.

The second comes from the exec node stdout, the the rc object has been expanded in the cut and paste, and shows code: 0

Looks the little triangles to indicate expansion didn't cut and paste the one in front of rc: would be pointing down.

---

<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:** [25 December 2020 08:24 UTC](https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992/4 "2020-12-25T08:24:10Z")

</div>

I don't think you will find it is the msg.payload appending that is the problem. One way to check is to remove the command from the `exec` node and add it to the msg.payload coming in and check the results.

another way to check is to use a different conmmand. Set the command to `ls` and pass in `/usr/bin` (or the home directory of the user running NR) and see what happens.

When I do that with your flow, I get an error (which is expected) since I don't have speak-ng installed

 ![Screen Shot 2020-12-25 at 3.02.06 AM](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9c63aa5a30c31ed8768dde74422461970ccc3f1.png)

The fact that the RC is 0 means the command was executed.

What platform are you running on?  
What version of node.js?  
does the user - on the new device - running NR have the privilege to run the command?  
could it be that espeak is trying to talk on the device running NR? (just speculating here.

---

<div class="post-metadata">

**Author:** ![wb666greene](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/wb666greene/32/6534_2.png) [@wb666greene](https://discourse.nodered.org/u/wb666greene)\
**Post date:** [25 December 2020 17:14 UTC](https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992/5 "2020-12-25T17:14:59Z")

</div>

Running the espeak command on the device running node red is the whole point, as that is where the audio amp and speakers are connected.

As I said its running v1.2.6

I assume that with the default bash script installation node-red runs as the same user where the .node-red directory gets created, which would be the same username as I do for the ssh connection.

The espeak command works when I give it over an ssh login.

I'm starting node-red as a service, does this start it as a different user? if so how does it read $HOME/.node-red/settings?

Still puzzled.

Have a Merry Christmas everyone!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [23 February 2021 17:15 UTC](https://discourse.nodered.org/t/msg-payload-not-being-appended-to-command-in-exec-node/37992/6 "2021-02-23T17:15:23Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
