# Echo statements from a bash script

**URL:** <https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266>\
**Category:** General\
**Created:** [9 February 2025 20:32 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266 "2025-02-09T20:32:56Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [9 February 2025 20:32 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/1 "2025-02-09T20:32:57Z")

</div>

I have a bash script which is run by using an exec node, on a timer.  
The script also generates `echo` statements, such as `echo "script started...` but they do not appear in any of the 3 exec node outputs.  
I really need the outputs because they would trigger other actions in a node-RED flow.

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [9 February 2025 20:44 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/2 "2025-02-09T20:44:01Z")

</div>

Are you using spawn mode?

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [9 February 2025 20:48 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/3 "2025-02-09T20:48:18Z")

</div>

I've tried both, but no outputs except `{ code: 0 }` when the script finishes.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 February 2025 21:01 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/4 "2025-02-09T21:01:07Z")

</div>

Are you redirecting stdout in the script?:

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [9 February 2025 21:15 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/5 "2025-02-09T21:15:27Z")

</div>

I've tried `echo "Starting daily backup..." >&1` which didn't work  
is that the correct way?

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [9 February 2025 21:22 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/6 "2025-02-09T21:22:27Z")

</div>

Julian's script redirects the stdout at the beginning. Try commenting out the exec1 to allow the echo to be sent to stdout.

---

<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:** [9 February 2025 21:26 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/7 "2025-02-09T21:26:37Z")

</div>

> [@Paul-Reed](#):
>
> I've tried `echo "Starting daily backup..." >&1`  
> is that the correct way?

As long as your exec node is set to output while the command is running - spawn mode, you should get a message generated by each echo command in your script.

`>&1` is definitely not needed.

Can you export the timer, exec and debug nodes to share?  
If the script is not confidential, share that too.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [9 February 2025 21:35 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/8 "2025-02-09T21:35:35Z")

</div>

> [@E1cid](#):
>
> Try commenting out the exec1 to allow the echo to be sent to stdout.

Thanks @E1cid that was the reason!!  
I've commented it out, and now I get the `echo` statements that I need 😀

---

<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:** [23 February 2025 21:35 UTC](https://discourse.nodered.org/t/echo-statements-from-a-bash-script/95266/9 "2025-02-23T21:35:59Z")

</div>

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