Set Linux shell environment variable

Hello,
in Node Red I need to set a Linux Shell environment variable, for instance SPEAKVOL=10

I tried everything, also to create a shell file:

#!/bin/sh
export SPEAKVOL=$1

and then adding an exec node with the command

source name_of_above_file.sh

but it is not working.
How can I do? Please help!

Thanks,
Dan

You could set the environment variable in the settings file as explained in below link.

from my understanding each shell instance has a unique set of environments.

If you run it under a bash script, when the shell ends after the script has run the variable dies with it

2 Likes

I would put the command you want to run in the second exec node into the script you want to source and just launch that script in a single exec node. Keeps things self-contained

Environmental variables are not global, but they can look that way because a "standard" set is generally created in various .bashrc and/or .profile files that are highly system dependent and loaded when a new login shell is created and possibly a different or null set when a non-interactive (not attached to a "terminal") shell is launched.

I try to avoid using environmental variables whenever possible.

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