# Problem with EXEC node and command line parameters

**URL:** https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542
**Category:** General
**Created:** [2 April 2021 10:23 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542 "2021-04-02T10:23:33Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Tontze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tontze/32/39657_2.png) [@Tontze](https://discourse.nodered.org/u/Tontze)
#### Post date: [2 April 2021 10:23 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/1 "2021-04-02T10:23:33Z")

</div>

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

```auto
sudo python3 read_wavemini.py 2920004430 10

```

It looks like it does not understand command line options:

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

usage: read_wavemini [-h] SERIAL_NUMBER SAMPLE_PERIOD

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

read_wavemini: error: unrecognized arguments: 1617359621080

2.4.2021 klo 13.33.41node: 734014ef.7c82a4msg.payload : Object
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 ?

-T

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2021 11:14 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/2 "2021-04-02T11:14:56Z")

</div>

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

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [2 April 2021 11:21 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/3 "2021-04-02T11:21:35Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Tontze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tontze/32/39657_2.png) [@Tontze](https://discourse.nodered.org/u/Tontze)
#### Post date: [2 April 2021 11:31 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/4 "2021-04-02T11:31:46Z")

</div>

@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 ?

```auto
[{"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 read_wavemini.py 2920004430 5","addpay":true,"append":"","useSpawn":"true","timer":"","oldrc":false,"name":"","x":1080,"y":820,"wires":[["734014ef.7c82a4"],["734014ef.7c82a4"],["734014ef.7c82a4"]]}]

```

![Sieppaa9](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/668cf36de87863e2c47fc00c2cd03edd4ff8d31c.png)

 ![Sieppaa10](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f95a9d4682aa7529a22cdb7f3260453ace43ce7f.png)

This is what is coming out from the .py :

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

```

---

<div class="post-metadata">

### Author: ![Tontze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tontze/32/39657_2.png) [@Tontze](https://discourse.nodered.org/u/Tontze)
#### Post date: [2 April 2021 12:06 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/5 "2021-04-02T12:06:57Z")

</div>

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 ..

---

<div class="post-metadata">

### Author: ![Tontze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tontze/32/39657_2.png) [@Tontze](https://discourse.nodered.org/u/Tontze)
#### Post date: [2 April 2021 12:16 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/6 "2021-04-02T12:16:53Z")

</div>

Hm ok, empty inject node seems to do the work 🙂

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [2 April 2021 12:20 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/7 "2021-04-02T12:20:51Z")

</div>

> [@Tontze](#):
>
> ![Sieppaa9](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/668cf36de87863e2c47fc00c2cd03edd4ff8d31c.png)

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.

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2021 12:31 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/8 "2021-04-02T12:31:32Z")

</div>

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 read_wavemini.py 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?

---

<div class="post-metadata">

### Author: ![Tontze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tontze/32/39657_2.png) [@Tontze](https://discourse.nodered.org/u/Tontze)
#### Post date: [2 April 2021 13:15 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/9 "2021-04-02T13:15:46Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [2 April 2021 14:25 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/10 "2021-04-02T14:25:38Z")

</div>

So is it all working now?

---

<div class="post-metadata">

### Author: ![Tontze](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tontze/32/39657_2.png) [@Tontze](https://discourse.nodered.org/u/Tontze)
#### Post date: [3 April 2021 03:33 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/11 "2021-04-03T03:33:31Z")

</div>

Yes it is, thank you all for helping 🙂

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [17 April 2021 03:34 UTC](https://discourse.nodered.org/t/problem-with-exec-node-and-command-line-parameters/43542/12 "2021-04-17T03:34:28Z")

</div>

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