Exec node, how to send [enter]?

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

Have you tried adding \n at the end?

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

1 Like

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.

1 Like

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

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=

1 Like

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

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.

1 Like

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

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 !!!

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/
Does the job for me wherever I need it to. This situation is slightly easier so echo | ... works just fine too.

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

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