# Exec node, how to send \[enter\]?

**URL:** <https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394>\
**Category:** General\
**Created:** [7 April 2020 11:55 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394 "2020-04-07T11:55:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![SammyG](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@SammyG](https://discourse.nodered.org/u/SammyG)\
**Post date:** [7 April 2020 11:55 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/1 "2020-04-07T11:55:38Z")

</div>

Hi,

i run node-red on a IOT2000 module from Siemens.  
I need to mount a shared folder from windows.  
It works if I do it with Putty (command promp).  
I send:  
`mount.cifs //192.168.1.58/Share /Recepten –o user=Iedereen`  
Then I get back :  
`Password for root@192.168.1.58/Share:`  
Since I don't have a password I just pres [enter] and it works.

Now I have to do this with node-red (so I can do it automaticly evertytime it boot up)  
I can send the first command:  
`mount.cifs //192.168.1.58/Share /Recepten –o user=Iedereen`  
But then I get back:  
`Password for root@192.168.1.58/Share:`

But how I need to answer on this? Do I need two exec nodes?  
I don't know how to deal with this in node-red

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

---

<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:** [7 April 2020 11:59 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/2 "2020-04-07T11:59:53Z")

</div>

Have you tried adding `\n` at the end?

`mount.cifs //192.168.1.58/Share /Recepten –o user=Iedereen\n`

---

<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:** [7 April 2020 12:01 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/3 "2020-04-07T12:01:49Z")

</div>

Actually that probably won't work. Its obviously entering the CMD. You want enter after the command responds.

Sure it's possible, but don't know at the moment. Sorry.

---

<div class="post-metadata">

**Author:** ![SammyG](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@SammyG](https://discourse.nodered.org/u/SammyG)\
**Post date:** [7 April 2020 12:04 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/4 "2020-04-07T12:04:22Z")

</div>

I've already tried that.  
Also with 2 nodes in a row, or in parallel with a delay in between.  
Without success.  
Thank you for thinking along

---

<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:** [7 April 2020 12:08 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/5 "2020-04-07T12:08:12Z")

</div>

Try....  
`mount.cifs //192.168.1.58/Share /Recepten –o user=Iedereen password=`

Or

`mount.cifs //192.168.1.58/Share /Recepten –o user=Iedereen, password=`

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 April 2020 12:14 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/6 "2020-04-07T12:14:20Z")

</div>

The exec node is only really designed to run "one" command. you may be able to do something like

```auto
echo | mount.cifs //192.168.1.58/Share /Recepten –o user=Iedereen

```

that may work - or the enter may get sent too quick...

The node-red-node-daemon node could be an alternative as that leaves the input side open for use as stdin so you can inject extra commands into the process at any time.

---

<div class="post-metadata">

**Author:** ![SammyG](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@SammyG](https://discourse.nodered.org/u/SammyG)\
**Post date:** [7 April 2020 12:23 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/7 "2020-04-07T12:23:58Z")

</div>

I have also try that already, but that doesn't seems to work for my module. Even with putty he still asks for a password

---

<div class="post-metadata">

**Author:** ![SammyG](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@SammyG](https://discourse.nodered.org/u/SammyG)\
**Post date:** [7 April 2020 12:26 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/8 "2020-04-07T12:26:23Z")

</div>

Yes! That is working!  
`echo | mount.cifs //192.168.1.58/Share /Recepten –o user=Iedereen`

Can you explain what the 'echo |' does?  
Thank you !!!

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [7 April 2020 13:00 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/9 "2020-04-07T13:00:13Z")

</div>

A different solution, for future readers finding this topic, would be to use `expect` and a script for it. I use it to insert non-empty passwords into processes without having to store the passwords in plain text in scripts or flows. This article is how I got started with expect: [https://likegeeks.com/expect-command/](https://likegeeks.com/expect-command/)  
Does the job for me wherever I need it to. This situation is slightly easier so `echo | ...` works just fine too.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [7 April 2020 13:15 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/10 "2020-04-07T13:15:44Z")

</div>

echo {something} | command - will pipe "something" into the command... and automatically adds an enter - so echo | will just send enter to the command. As long as that is all you needed then phew... anything more complex than a single word plus enter then use the expect command/script as suggested by @afelix

---

<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:** [21 April 2020 13:15 UTC](https://discourse.nodered.org/t/exec-node-how-to-send-enter/24394/11 "2020-04-21T13:15:55Z")

</div>

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