# Problem with exec node output in Spawn mode

**URL:** <https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902>\
**Category:** General\
**Created:** [8 February 2023 17:23 UTC](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902 "2023-02-08T17:23:24Z")\
**Posts on this page:** 6\
**Page:** 2

<div class="post-metadata">

**Author:** ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)\
**Post date:** [14 February 2023 21:47 UTC](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902/21 "2023-02-14T21:47:03Z")

</div>

I uninstalled the nodes that gave warning messages in the log, now the startup log is clean

```auto
pi@raspberrypi:~ $ node-red-start

Start Node-RED
 
Once Node-RED has started, point a browser at http://192.168.178.210:1880
On Pi Node-RED works better with the Firefox or Chrome browser
 
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
 
To find more nodes and example flows - go to http://flows.nodered.org
 
Starting as a systemd service.
Started Node-RED graphical event wiring tool..
14 Feb 22:43:12 - [info]
Welcome to Node-RED
===================
14 Feb 22:43:12 - [info] Node-RED version: v3.0.2
14 Feb 22:43:12 - [info] Node.js version: v16.19.0
14 Feb 22:43:12 - [info] Linux 4.19.66-v7+ arm LE
14 Feb 22:43:14 - [info] Loading palette nodes
14 Feb 22:43:18 - [info] Dashboard version 2.10.1 started at /ui
14 Feb 22:43:18 - [info] Settings file : /home/pi/.node-red/settings.js
14 Feb 22:43:18 - [info] Context store : 'default' [module=memory]
14 Feb 22:43:18 - [info] User directory : /home/pi/.node-red
14 Feb 22:43:18 - [warn] Projects disabled : set editorTheme.projects.enabled=true to enable
14 Feb 22:43:18 - [warn] Flows file name not set. Generating name using hostname.
14 Feb 22:43:18 - [info] Flows file : /home/pi/.node-red/flows_raspberrypi.json
14 Feb 22:43:18 - [info] Server now running at http://127.0.0.1:1880/
14 Feb 22:43:18 - [warn]
---------------------------------------------------------------------
Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.
---------------------------------------------------------------------
14 Feb 22:43:19 - [info] Starting flows
14 Feb 22:43:19 - [info] Started flows

```

Is it possible to rename the post title?  
from  
_"How to read the output of BIGEXEC nodes"_  
to  
_"How to read the output of EXEC / BIGEXEC node"_

---

<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 February 2023 22:05 UTC](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902/22 "2023-02-14T22:05:35Z")

</div>

> [@batigolle](#):
>
> Is it possible to rename the post title?

Yes, click on the pen by the title at the top.

The log looks fine, so it is all a bit odd.

If you kill the process (you can do that by sending in a message with msg.kill set, as described in the help text for the node) then does the output all appear?  
If you set the exec node to output on completion and then kill the process does it all appear?

---

<div class="post-metadata">

**Author:** ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)\
**Post date:** [16 February 2023 10:40 UTC](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902/23 "2023-02-16T10:40:03Z")

</div>

> [@Colin](#):
>
> Yes, click on the pen by the title at the top.

I can't find any pen, maybe too much time has passed,  
it had to be done within the first few days

> [@Colin](#):
>
> If you set the exec node to output on completion and then kill the process does it all appear?

If Kill the process no 'printf' messages appear  
just this message

```auto
Exec mode : msg : Object
object
_msgid: "2455c01b1300d406"
topic: "Exec mode"
payload: object
code: null
message: string
Command failed: /home/pi/RadioHead/examples/raspi/rf95/./rf95_server
signal: "SIGTERM"

```

**I ran another simple test**  
**to easily reproduce the problem, of which I'm looking for the solution**

I created a small C program that prints messages every 3 sec ( test.c )

```auto
#include <stdio.h>
#include <unistd.h>

int main(){
 
   printf("Hello 1 \n"); 
   sleep(3);
   printf("Hello 2 \n"); 
   sleep(3);
   printf("Hello 3 \n"); 
   sleep(5);
         }

```

Running this simple program, I would expect to see "Hello" messages in the MSG node while it's running, but these only appear, all at once, when the program completes.

```auto
16/2/2023, 11:35:42node: MSG OUT
msg : Object
object
payload: string
Hello 1 
Hello 2 
Hello 3 
_msgid: "df5f8c79f71bc001"

```

@Colin ,what do you suggest,  
should I open a new request post, with this simple program and exec node  
or shall we continue here?

---

<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:** [16 February 2023 13:34 UTC](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902/24 "2023-02-16T13:34:53Z")

</div>

C may be buffering the output. Google suggests you can force a flush using  
`fflush(stdout);`  
after each printf.  
Alternatively you may get the same effect by adding at the top  
`setbuf(stdout, NULL);`

**[Edit]** I have edited the thread title for you.

---

<div class="post-metadata">

**Author:** ![batigolle](https://avatars.discourse-cdn.com/v4/letter/b/ee59a6/32.png) [@batigolle](https://discourse.nodered.org/u/batigolle)\
**Post date:** [16 February 2023 15:23 UTC](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902/25 "2023-02-16T15:23:39Z")

</div>

> [@Colin](#):
>
> I have edited the thread title for you.

Thanks a lot !

@Colin  
I added the command

```auto
fflush(stdout);

```

after the line 'printf(......);' in the original C source of the LORA receiver

```auto
  if (rf95.recv(buf, &len)) {
            printf("Packet[%02d] #%d => #%d %ddB: ", len, from, to, rssi);
            printbuffer(buf, len);
            fflush(stdout); //LP
          } else {
            Serial.print("receive failed");
          }
          printf("\n");
        }

```

**works !!!**  
**I can intercept messages arriving on my Raspberry LORA Gateway  
and process them in Node-Red nodes**

```auto
16/2/2023, 16:09:16node: 38f6c324aee3f8bf
Spawn mode : msg : Object
object
_msgid: "aa3831d610fac0de"
payload: "rf95_server↵RF95 CS=GPIO25, IRQ=GPIO4, RST=GPIO17, LED=GPIO255 OK NodeID=1 @ 868.00MHz↵Listening packet...↵Packet[16] #255 => #255 -25dB: 33 75 10 00 FF 05 18 00 66 66 A2 41 00 00 B0 42"
topic: "Spawn mode"
16/2/2023, 16:09:49node: 38f6c324aee3f8bf
Spawn mode : msg : Object
object
_msgid: "aa3831d610fac0de"
payload: "↵Packet[16] #255 => #255 -26dB: 33 75 10 00 90 04 19 00 66 66 A2 41 00 00 B0 42"
topic: "Spawn mode"

```

**Thank you so much for the help you have given me**  
**Good da** y

---

<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:** [2 March 2023 15:23 UTC](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902/26 "2023-03-02T15:23:58Z")

</div>

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

[Previous page](https://discourse.nodered.org/t/problem-with-exec-node-output-in-spawn-mode/74902.md?page=1)
