Problem with EXEC node and command line parameters

Im trying to execute and get output to debug node. My command is :

sudo python3 2920004430 10

It looks like it does not understand command line options:

2.4.2021 klo 13.33.41node: 734014ef.7c82a4
msg.payload : string[54]

usage: read_wavemini [-h] SERIAL_NUMBER SAMPLE_PERIOD

2.4.2021 klo 13.33.41node: 734014ef.7c82a4msg.payload : string[60]

read_wavemini: error: unrecognized arguments: 1617359621080

2.4.2021 klo 13.33.41node: 734014ef.7c82a4msg.payload : Object
code: 2

It runs, if i disable msg.payload, but then i dont get anything to any outputs of the exec node ?
When it runs, it stays on and tries to report things, so im using spawn mode.

Can someone explain me how to make it work ?


Add a debug node showing what is going into the exec node and show us (screenshot) how you have configured the exec node.

Under normal usage you can’t use sudo in an exec node as that is a escalation of privileges exception. To run an app as sudo you need either run the whole of node-red as root or allow the app (python) to have admin privileges.

@Colin i have only inject node before exec node. @dceejay i have setup my system so that sudo is not asking password for user im using, isnt that enough ?

[{"id":"734014ef.7c82a4","type":"debug","z":"e1366dff.7c47f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1390,"y":820,"wires":[]},{"id":"d66801d6.8e86f","type":"inject","z":"e1366dff.7c47f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":820,"y":820,"wires":[["7bdb1043.f2bec8"]]},{"id":"7bdb1043.f2bec8","type":"exec","z":"e1366dff.7c47f8","command":"sudo python3 2920004430 5","addpay":true,"append":"","useSpawn":"true","timer":"","oldrc":false,"name":"","x":1080,"y":820,"wires":[["734014ef.7c82a4"],["734014ef.7c82a4"],["734014ef.7c82a4"]]}]


This is what is coming out from the .py :

Temperature: 24.42 *C, Humidity: 29.46 %rH, VOC: 101 ppm

i c that i propably need to format inject node somehow, but how ?) exec node doesnt need any parameters, just needs to run.

Im still learning ..

Hm ok, empty inject node seems to do the work :slight_smile:

You were appending msg.payload to your command. So you where adding 1617359621080 to the end of your command , as msg.payload was a timestamp.

By telling it to append msg.payload then it will add the timestamp to the end of the command, so the command it runs will be something like
sudo python3 2920004430 5 1617366502827
Is that what you want?

When you run it in a terminal do you just execute the command and the answer appears immediately or do you have to enter something via the keyboard?

No it really wasnt what i wanted :slight_smile: in console, i just run that command, nothing more needed. It stays running and outputs once in a while.

So is it all working now?

Yes it is, thank you all for helping :slight_smile:

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