Can a function access the values in the settings.js file?

176 views
Skip to first unread message

Paul Woodard

unread,
Jan 6, 2016, 7:49:42 AM1/6/16
to Node-RED
Is it possible for a function node to access the things set in settings.js? For example I want to get the name of the flow file. I know it defaults to flows_<hostname>.json but it could have been set to something different in settings.js. 


Nicholas O'Leary

unread,
Jan 6, 2016, 8:22:28 AM1/6/16
to Node-RED Mailing List
No, it only has access to things under functionGlobalContext property within the settings file.



On 6 January 2016 at 12:49, Paul Woodard <zeno...@zenofmud.org> wrote:
Is it possible for a function node to access the things set in settings.js? For example I want to get the name of the flow file. I know it defaults to flows_<hostname>.json but it could have been set to something different in settings.js. 


--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Josh Conway

unread,
Jan 7, 2016, 4:43:25 PM1/7/16
to Node-RED
That's not entirely true... Heh heh heh.

Use "Inject", "exec", and "debug"

[{"id":"780bd2d4.017dd4","type":"inject","z":"20240cab.96b054","name":"","topic":"","payload":"","payloadType":"none","repeat":"","crontab":"","once":false,"x":81,"y":80,"wires":[["a398cebc.83fd4"]]},{"id":"a398cebc.83fd4","type":"exec","z":"20240cab.96b054","command":"cat ~/.node-red/settings.js","addpay":true,"append":"","useSpawn":"","name":"","x":273,"y":81,"wires":[["40de8c1c.e0ac5c"],[],[]]},{"id":"40de8c1c.e0ac5c","type":"debug","z":"20240cab.96b054","name":"","active":true,"console":"false","complete":"false","x":518,"y":67,"wires":[]}]

Now, all you need do is write a parser. :-D



Also, if your Node-Red user can SUDO, you can also apt administration via a flow. For example...

$echo <password> | sudo -S <command>

and with this you can run whatever as root. Preferrably, you can do apt-get install {{payload}}

$echo <password> | sudo -S apt-get install {{payload}}

for easy package additions.
Reply all
Reply to author
Forward
0 new messages