How to run a bash script from node red?


Sorry folks, I’ve tried searching and the results were somewhat unhelpful.

I am wanting to invoke a shell script (bash script?) from Node-red.

I tried the exec node, but no luck.

Found “BIGEXE” and that didn’t work either.

I don’t need any extra stuff. The whole name is sent to the node upon invocation.


Exec node cannot find any of my commands

The exec node is exactly what you want.

What didn’t work about it? Any error messages etc? How did you have it configured?




This is embarrassing for me.

I don’t know why it is, but sometimes I have to ask a “dumb” question before I can resolve it myself.

What I missed is in the EXEC node I was only entering the file name of the script I wanted to run.
I now realise I have to enter:
bash (filename)
and it works.

I am sorry.

Believe me, I don’t like to waste people’s time.



Just on this, kinda…

I see there is a place where people can upload their own flows.

I have a couple which only use the standard nodes and may be handy for people.

Is it ok if I do so?

Alas there is a slight caviet (spelling?) that it uses an external bash script in what it does to achieve everything.

I don’t want to upload stuff which won’t work “as is” but if it needs external (or foreign) stuff, I don’t know how to include it as a part of the package.



no problem - you could also possibly set your script to be executable eg chmod +x and then you may not need to call bash… but yes lots of ways to do his.



Yeah, thanks.

It was more that I was completely missing the BASH part.

So in the “execute” filed I was only putting the file name.

Suddenly it hit me that I need to put bash then the file name.

All working now.



If the file has been made executable and the first line of the file is
then you should just be able to put the full path to the script in the exec node.



I use bash scripts to backup Node Red and Motion files from Pi systems in my network. I run this with Node Red running on Ubuntu. I had file permission issues until I placed the bash script into my .node-red directory.
Now, using Node Red, I can automate the backup of all the Pi systems in my network.
The exec node just needs the file path: /home/will/.node-red/ with 'append' unchecked.
I set the file to executable.
Sample bash code:

#back up Node Red and motion files from remote Pi to Dropbox
#I run this with Node Red running on Ubuntu 18.04
#I place this bash file in my .node-red directory

#sprinkler-204 is my sprinkler system pi at
#it runs Node Red and also a motion cam inside my garage

#espeak needs to be installed for audible speach
#delete the espeak lines if you don't want to hear them
espeak "204 file backup in progress"

today=`date +%Y-%m-%d.%H:%M:%S`

espeak "creating updated directories"
#make new directories named with time stamp
mkdir /home/will/Dropbox/net/sprinkler-204/motion/old/$today
mkdir /home/will/Dropbox/net/sprinkler-204/node-red/old/$today

espeak "moving old files"
#move previous backup files to new directories
mv /home/will/Dropbox/net/sprinkler-204/motion/*.* /home/will/Dropbox/net/sprinkler-204/motion/old/$today
mv /home/will/Dropbox/net/sprinkler-204/node-red/*.* /home/will/Dropbox/net/sprinkler-204/node-red/old/$today

espeak "getting files from pi"
#backup current files from the pi
#ssh keys need to be set up for this to work without a password
scp pi@* /home/will/Dropbox/net/sprinkler-204/motion
scp pi@*.* /home/will/Dropbox/net/sprinkler-204/node-red