# Exec node output

**URL:** <https://discourse.nodered.org/t/exec-node-output/45620>\
**Category:** General\
**Created:** [14 May 2021 00:52 UTC](https://discourse.nodered.org/t/exec-node-output/45620 "2021-05-14T00:52:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kenkoknz](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@kenkoknz](https://discourse.nodered.org/u/kenkoknz)\
**Post date:** [14 May 2021 00:52 UTC](https://discourse.nodered.org/t/exec-node-output/45620/1 "2021-05-14T00:52:24Z")

</div>

Hi, linux noob, just mucking round with the exec node:

 ![Screenshot 2021-05-14 123853](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/73cab12c66d06f3d374610d9c6a68a2133ae65db.png)

Why does the payload of the command sometimes display human readable ascii string and sometimes hex:

e.g with ls -a cmd, display a nice string of human readable ascii:

 ![Screenshot 2021-05-14 123806](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/1/11edaf20a91e039a112c3a79ce2bec4a6742323a.png)

with cat /sys/firmware/devicetree/base/model:

 ![Screenshot 2021-05-14 121721](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/8/9805933824c0953cd29510c88b77e9ac7c00e2e4.png)

While a function node can change it to readable string:  
msg.payload = Buffer.from(msg.payload);  
msg.payload = msg.payload.toString();  
return msg;

jus like to understand why it does not display ascii string in the first instance.

Thanks  
Ken

---

<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:** [14 May 2021 07:22 UTC](https://discourse.nodered.org/t/exec-node-output/45620/2 "2021-05-14T07:22:41Z")

</div>

What do you see if you run the cat command in a terminal?  
Also show us how you have configured the exec node.

---

<div class="post-metadata">

**Author:** ![kenkoknz](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@kenkoknz](https://discourse.nodered.org/u/kenkoknz)\
**Post date:** [14 May 2021 07:43 UTC](https://discourse.nodered.org/t/exec-node-output/45620/3 "2021-05-14T07:43:48Z")

</div>

When I run in the cmd terminal I see:  
Raspberry Pi 3 Model B Rev 1.2

 ![Screenshot 2021-05-14 193812](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/7/2759c0797dbcb89cfbcb2b0743723816cd708984.png)

The exec node config:

 ![Screenshot 2021-05-14 193424](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/b/6bfd84674162fb252889383853d51d563523254b.png)

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [14 May 2021 07:47 UTC](https://discourse.nodered.org/t/exec-node-output/45620/4 "2021-05-14T07:47:49Z")

</div>

Hi Ken,

Please try the following:

`cat -u`

```auto
ie: man cat
....
- u The output is not buffered

```

Cheers  
Ranki

---

<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:** [14 May 2021 08:13 UTC](https://discourse.nodered.org/t/exec-node-output/45620/5 "2021-05-14T08:13:05Z")

</div>

Can you show us the whole of the buffer output please. The help text for the exec node says  
The returned `payload` is usually a _string_ , unless non-UTF8 characters are detected, in which case it is a _buffer_ .  
which suggests that there is a non-ascii character there. In fact, before posting it look at it and see if there are any unusual characters there. Find an ascii table to check it against. I note that the buffer is 31 characters but the text output is 30 and there is no newline on the end. I suspect that there may be a null character on the end, or something similar.

---

<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:** [14 May 2021 08:59 UTC](https://discourse.nodered.org/t/exec-node-output/45620/6 "2021-05-14T08:59:56Z")

</div>

Indeed on a Pi at least there is a 0x00 at the end of the string... a quick way to trim it is to add ` | xargs` to the command in the exec node - so

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/d/2d21ecd560ee110a5f2f533007741425c040879d.png)

---

<div class="post-metadata">

**Author:** ![kenkoknz](https://avatars.discourse-cdn.com/v4/letter/k/58956e/32.png) [@kenkoknz](https://discourse.nodered.org/u/kenkoknz)\
**Post date:** [15 May 2021 03:22 UTC](https://discourse.nodered.org/t/exec-node-output/45620/7 "2021-05-15T03:22:08Z")

</div>

Hi @Colin, the whole buffer output is (I think is decimal, when I copy & paste):  
[82,97,115,112,98,101,114,114,121,32,80,105,32,51,32,77,111,100,101,108,32,66,32,82,101,118,32,49,46,50,0], and does look like a 0 is sent at the end as per @dceejay said, but I thought 0 is valid null ASCII chr.  
Does not explain why on the same pi, cmd ls -a, does not buffer and outputs string as I would expect.

@Ranki, thanks for the suggestion, that works & save me another function node to convert to string, just curious why some command buffer & some dont. Hope u are enjoying your boating, I am working on a seatalk to nmea converter and hope to display all my instruments in NR's Dashboard.

Thanks,  
Ken  
NZ

---

<div class="post-metadata">

**Author:** ![Ranki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ranki/32/41282_2.png) [@Ranki](https://discourse.nodered.org/u/Ranki)\
**Post date:** [15 May 2021 07:32 UTC](https://discourse.nodered.org/t/exec-node-output/45620/8 "2021-05-15T07:32:36Z")

</div>

Hi @kenkoknz ,

Good to hear that it is working now. In the end I think the problem is not the exec node, but the general output of cat on Linux; therefore they introduced this parameter. We need to ask them why 🙃

Concerning the boat project: good look! 🙂

Cheers  
Ranki

---

<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:** [14 July 2021 07:32 UTC](https://discourse.nodered.org/t/exec-node-output/45620/9 "2021-07-14T07:32:48Z")

</div>

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