# How to send output of one python script to another in Node-RED?

**URL:** https://discourse.nodered.org/t/how-to-send-output-of-one-python-script-to-another-in-node-red/59936
**Category:** General
**Created:** [16 March 2022 16:40 UTC](https://discourse.nodered.org/t/how-to-send-output-of-one-python-script-to-another-in-node-red/59936 "2022-03-16T16:40:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)
#### Post date: [16 March 2022 16:40 UTC](https://discourse.nodered.org/t/how-to-send-output-of-one-python-script-to-another-in-node-red/59936/1 "2022-03-16T16:40:03Z")

</div>

Sorry if this is too trivial. I have the following proof-of-concept scenario:

 ![nodeRedQuestion](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cb060da49720a1377283afecdcdea3adcdeb6422.png)

Both scripts run continuously. Script 1:

```auto
while True:
    print("Hello ")

```

Script 2:

```auto
while True:
    print("World")

```

The **script 2** will only print if it gets an input from **script 1**. I was looking at `daemon` and `exec` nodes, but got confused.

---

<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: [16 March 2022 16:58 UTC](https://discourse.nodered.org/t/how-to-send-output-of-one-python-script-to-another-in-node-red/59936/2 "2022-03-16T16:58:39Z")

</div>

It seems a complicated way of printing `Hello World` so I guess you have simplified things somewhat.

Can't you use just one script, or call script2 directly from script1?  
If the scripts are running continuously, the exec node is the wrong approach since it will attempt to start another instance of the script.

With a situation like this, on Linux, I would set up the script[s] as systemd jobs and pass data to and from Node-red by MQTT.

---

<div class="post-metadata">

### Author: ![hkayan](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hkayan/32/42713_2.png) [@hkayan](https://discourse.nodered.org/u/hkayan)
#### Post date: [16 March 2022 19:25 UTC](https://discourse.nodered.org/t/how-to-send-output-of-one-python-script-to-another-in-node-red/59936/3 "2022-03-16T19:25:26Z")

</div>

> It seems a complicated way of printing `Hello World` so I guess you have simplified things somewhat.

Yes, that is just a proof of concept.

> would set up the script[s] as systemd jobs and pass data to and from Node-red by MQTT.

I appreciate if you can provide a MWE for this.

---

<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: [16 March 2022 19:49 UTC](https://discourse.nodered.org/t/how-to-send-output-of-one-python-script-to-another-in-node-red/59936/4 "2022-03-16T19:49:45Z")

</div>

The magic search words are probably "python paho mqtt callback".

---

<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: [15 May 2022 19:50 UTC](https://discourse.nodered.org/t/how-to-send-output-of-one-python-script-to-another-in-node-red/59936/5 "2022-05-15T19:50:04Z")

</div>

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