# Exec node with "timedatectl" call started to return a buffer instead of string

**URL:** <https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553>\
**Category:** General\
**Created:** [1 December 2021 08:55 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553 "2021-12-01T08:55:45Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![janedoe123](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@janedoe123](https://discourse.nodered.org/u/janedoe123)\
**Post date:** [1 December 2021 08:55 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/1 "2021-12-01T08:55:45Z")

</div>

Hi all,

I'm facing a super weird issue. I'm using an exec node with a "timedatectl" call, but suddenly it started to return a buffer instead of string.

Because of that, I can't use any JSONata expression anymore since my payload is a buffer and not a string.

Do you have any idea as to how to change the exec node payload output back to a string instead of a buffer ?

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [1 December 2021 08:58 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/2 "2021-12-01T08:58:39Z")

</div>

Could you post an example of what your doing with the exec node?

And maybe some info what a "timedatectl" call is

And OS info would be handy as well

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [1 December 2021 09:04 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/4 "2021-12-01T09:04:10Z")

</div>

Can you post whole of that flow and not just the last node please 🙂

---

<div class="post-metadata">

**Author:** ![janedoe123](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@janedoe123](https://discourse.nodered.org/u/janedoe123)\
**Post date:** [1 December 2021 09:05 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/5 "2021-12-01T09:05:08Z")

</div>

Oooops my bad !

```auto
[
    {
        "id": "d6cd57fac03f2437",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "64889f2be479953a",
        "type": "exec",
        "z": "d6cd57fac03f2437",
        "command": "timedatectl status",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "",
        "x": 710,
        "y": 280,
        "wires": [
            [
                "dee75bd8f498bd95"
            ],
            [],
            []
        ]
    },
    {
        "id": "547181a76e756d21",
        "type": "inject",
        "z": "d6cd57fac03f2437",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 500,
        "y": 280,
        "wires": [
            [
                "64889f2be479953a"
            ]
        ]
    },
    {
        "id": "dee75bd8f498bd95",
        "type": "switch",
        "z": "d6cd57fac03f2437",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "Local time:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Universal time:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "RTC time:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "Time zone:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "NTP synchronized:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "NTP enabled:",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "RTC in local TZ:",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 7,
        "x": 930,
        "y": 280,
        "wires": [
            [
                "9c38b86ef7bc180c",
                "4b6de73a7bb007d1"
            ],
            [],
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "9c38b86ef7bc180c",
        "type": "change",
        "z": "d6cd57fac03f2437",
        "name": "Create JSON Payload",
        "rules": [
            {
                "t": "set",
                "p": "ntp",
                "pt": "msg",
                "to": "{\t \"localTime\" : $substringAfter(msg.payload,'Local time: ')\t}",
                "tot": "jsonata"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "4b6de73a7bb007d1",
        "type": "debug",
        "z": "d6cd57fac03f2437",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1080,
        "y": 160,
        "wires": []
    }
]

```

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 December 2021 09:11 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/6 "2021-12-01T09:11:24Z")

</div>

Your flow works for me on RPiOS. The output from the change node seems to be identical to the input though.

Since the exec node (for me) returns a single, multiline, string, the switch node sends the whole payload to each output.

If I undertand what you are trying to achieve, inserting a split node after the exec breaks the string up into individual lines which are then routed correctly by the switch. The change still does nothing.

 ![Untitled 1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a44a48fa7e56049335f807e818164c530f51b85.jpeg)

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [1 December 2021 09:11 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/7 "2021-12-01T09:11:38Z")

</div>

Unfortunately, that command doesn't work on my Pi so can't test further  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/4/b477b94ea84a9727aa09d241816f74edfc0da47d.png)  
Sorry for wrong pic 1st time!

But I'd just consider switching NR/computer off and on again to just make sure its just not got upset!

---

<div class="post-metadata">

**Author:** ![janedoe123](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@janedoe123](https://discourse.nodered.org/u/janedoe123)\
**Post date:** [1 December 2021 09:35 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/9 "2021-12-01T09:35:46Z")

</div>

> [@jbudd](#):
>
> Since the exec node (for me) returns a single, multiline, string, the switch node sends the whole payload to each output.

Sorry, I lost you...

Indeed the exec node will return a single, multiline, string.

Do you mean to say that at the end of each line, there is no carriage return \n ?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [1 December 2021 09:44 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/10 "2021-12-01T09:44:05Z")

</div>

> [@janedoe123](#):
>
> Do you mean to say that at the end of each line, there is no carriage return \n ?

No. I should have posted the output I get from the exec node:

```auto
               Local time: Wed 2021-12-01 09:41:57 GMT
           Universal time: Wed 2021-12-01 09:41:57 UTC
                 RTC time: n/a
                Time zone: Europe/London (GMT, +0000)
System clock synchronized: yes
              NTP service: active
          RTC in local TZ: no

```

What do you mean by "it started to return a buffer instead of a string"?  
You should have posted the output you get from the exec node...

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [1 December 2021 09:53 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/12 "2021-12-01T09:53:17Z")

</div>

🤣

Best thread so far today 🙂

---

<div class="post-metadata">

**Author:** ![janedoe123](https://avatars.discourse-cdn.com/v4/letter/j/b19c9b/32.png) [@janedoe123](https://discourse.nodered.org/u/janedoe123)\
**Post date:** [1 December 2021 10:04 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/13 "2021-12-01T10:04:22Z")

</div>

Hahaha I don't know how I should take it... 😅

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [1 December 2021 10:42 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/14 "2021-12-01T10:42:33Z")

</div>

Meant in purely nice way - we've all done such things 🙂

Well I have anyway 🙂

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [1 December 2021 16:01 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/15 "2021-12-01T16:01:09Z")

</div>

Reminds me of the old joke about whether we are running UNIX or Unix or unix....

---

<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:** [30 January 2022 16:01 UTC](https://discourse.nodered.org/t/exec-node-with-timedatectl-call-started-to-return-a-buffer-instead-of-string/54553/16 "2022-01-30T16:01:33Z")

</div>

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