# How to trigger a node-red flow from shell script process or from systemctl service

**URL:** <https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300>\
**Category:** General\
**Created:** [5 February 2020 09:06 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300 "2020-02-05T09:06:04Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://discourse.nodered.org/u/Jasper)\
**Post date:** [5 February 2020 09:06 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/1 "2020-02-05T09:06:04Z")

</div>

hello everyone,

I would like to know if is possible trigger a node-red flow from a shell script process or from a systemctl service when the server is started up. Could you help me? Thank you in advance

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [5 February 2020 09:07 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/2 "2020-02-05T09:07:58Z")

</div>

Hi @Jasper

You could create a flow that listened for an incoming HTTP Request, and then use curl in your shell script to trigger it. Similarly, you could use the TCP Node and netcat. Lots of different options - depends which you think suits your needs.

---

<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:** [5 February 2020 09:23 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/3 "2020-02-05T09:23:40Z")

</div>

Or simple sledgehammer techniques like watching a log file for text indicating something of interest is happening.  
And there is always MQTT of course, you could publish to it from the script.

---

<div class="post-metadata">

**Author:** ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://discourse.nodered.org/u/Jasper)\
**Post date:** [5 February 2020 10:14 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/4 "2020-02-05T10:14:19Z")

</div>

Thank you all for your answers.

What I want to do is have a node-red flow subscribed to a specific MQTT topic to keep track and control based on the information received from that topic. For it, the node-red flow has to instantiated by a shell script process or by a systemctl service when starting the server where it is stayed

---

<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:** [5 February 2020 11:02 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/5 "2020-02-05T11:02:24Z")

</div>

> [@Jasper](#):
>
> the node-red flow has to instantiate

Can you explain what you mean by that? Node red flows are running all the time that node red is running, waiting for messages or events. If you configure an MQTT node subscribed to a topic then it will generate messages whenever MQTT gives it data. There is no need to instantiate the flow.

---

<div class="post-metadata">

**Author:** ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://discourse.nodered.org/u/Jasper)\
**Post date:** [5 February 2020 12:03 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/6 "2020-02-05T12:03:28Z")

</div>

I intend to have a flow that receives information from several sensors and that registry that information on a data base as a history without the need for a user to run a dashboard that subscribes to a specific MQTT topic

---

<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:** [5 February 2020 12:27 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/7 "2020-02-05T12:27:34Z")

</div>

Again I don't understand, what _exactly_ do you mean by "a user to run a dashboard that subscribes to a specific MQTT topic". You don't need to run a dashboard. Just configure MQTT input nodes to subscribe to the topics you want and they will send messages when data are received. There is no need for any dashboard.

---

<div class="post-metadata">

**Author:** ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://discourse.nodered.org/u/Jasper)\
**Post date:** [5 February 2020 13:46 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/8 "2020-02-05T13:46:24Z")

</div>

Thanks Collin, excuse my ignorance but it is my first project on node-red. As I understand you, if I configure an MQTT node on a flow, it will automatically receive messages from the topic to which it is subscribed by simply deploying that flow, Am I right?

---

<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:** [5 February 2020 13:49 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/9 "2020-02-05T13:49:24Z")

</div>

> [@Jasper](#):
>
> Am I right?

Yes you are! 🎇 🎉

---

<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:** [5 February 2020 13:57 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/10 "2020-02-05T13:57:52Z")

</div>

One of the great things about node-red is the sort of tool that you can easily experiment with. You could have answered your own question by simply trying it and feeding the output of the MQTT node into a debug node.

---

<div class="post-metadata">

**Author:** ![Jasper](https://avatars.discourse-cdn.com/v4/letter/j/cdc98d/32.png) [@Jasper](https://discourse.nodered.org/u/Jasper)\
**Post date:** [5 February 2020 14:19 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/11 "2020-02-05T14:19:24Z")

</div>

I will try it tonight when I arrive to my home. Thanks again.

---

<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:** [5 April 2020 14:19 UTC](https://discourse.nodered.org/t/how-to-trigger-a-node-red-flow-from-shell-script-process-or-from-systemctl-service/21300/12 "2020-04-05T14:19:28Z")

</div>

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