Child_process.exec [deginner need help]

Hi all,
I would like to make a button in the dashboard to execute a script. This script updates Node-Red like this:
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)

In this previous post @TotallyInformation suggests that I use an exec node which will create a shell which can execute what I want with chil_process.exec.

The problem is that I am completely new to programming and I do not see how to write this script.
Can you help me ?
Thanks
Chris

Start here, there are a lot of resources on-line:

https://linuxconfig.org/bash-scripting-tutorial-for-beginners

Your "environment" is not inherited when you use an exec node so you need to use the full path to the curl command. On my system its /usr/bin/curl

Will that work, doesn't it need to be run in terminal so that you can enter the password when required. Or are your systems setup so as not to need a password for sudo?
Even then I am not certain it will work without a terminal session.

Apart from the comments from @Colin, which are relevant, why do you want to update node-red this way? The biggest problem I see is that you wouldn't see installation errors, if they occur.

the goal is to display on the Dashboard if a new version of NR is available online :

and if there is one, be able to update always from the Dashboard by clicking on a button which executes the update command or script.
Indeed, we do not see the errors but it avoids connecting to ssh and typing in the terminal to the update command.

If it is just node-red that you want to update then you could run directly using an exec node
sudo npm install -g --unsafe-perm node-red
and then force a node-red restart or a reboot.

Edit - corrected command above.

1 Like

it works, it does the job thanks for the help.

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