# Exec-Node: Works fine in Linux Terminal, but not in Exec-Node

**URL:** <https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126>\
**Category:** General\
**Tags:** exec\
**Created:** [13 November 2024 16:37 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126 "2024-11-13T16:37:29Z")\
**Posts on this page:** 7\
**Page:** 3

<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:** [16 November 2024 09:59 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126/41 "2024-11-16T09:59:04Z")

</div>

> [@PeterSmarthome](#):
>
> Also in alternative to using the smartthings CLI script, you could call the RestAPIs directly using a http-request node,

That may well be the best plan.

---

<div class="post-metadata">

**Author:** ![PeterSmarthome](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@PeterSmarthome](https://discourse.nodered.org/u/PeterSmarthome)\
**Post date:** [16 November 2024 10:24 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126/42 "2024-11-16T10:24:42Z")

</div>

I'll try that.

Also just realized there is a node-red smarthings contrib 🙄

[https://flows.nodered.org/node/node-red-contrib-smartthings](https://flows.nodered.org/node/node-red-contrib-smartthings)

Let's see how these are going...

---

<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:** [16 November 2024 10:51 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126/43 "2024-11-16T10:51:33Z")

</div>

> [@PeterSmarthome](#):
>
> [node-red-contrib-smartthings (node) - Node-RED](https://flows.nodered.org/node/node-red-contrib-smartthings)

Looking at the[issues page for that node](https://github.com/otaviojr/node-red-contrib-smartthings/issues) there are numerous unadressed issues, so it may be that the node is not longer supported.

---

<div class="post-metadata">

**Author:** ![PeterSmarthome](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@PeterSmarthome](https://discourse.nodered.org/u/PeterSmarthome)\
**Post date:** [16 November 2024 14:03 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126/44 "2024-11-16T14:03:40Z")

</div>

> [@bakman2](#):
>
> could you try your script using this:
> 
> ```auto
> #!/bin/bash
> /usr/bin/smartthings devices:commands xxxxxx-xxxx-xxxx-xxxx-xxxxxxx --token=xxxxxx-xxxx-xxxx-xxxx-xxxxxxx 'main:execute:execute("/mode/vs/0",{"x.com.samsung.da.options":["Sound_Off"]})' & PID=$!; sleep 3; kill -s SIGINT $PID
> 
> ```
> 
> it will capture its PID and kills it after 3 seconds. Run it in exec mode.

So this is what happens:

`{"_msgid":"49ab6b798649273d","topic":"","payload":"Command executed successfully\n","rc":{"code":1,"message":"Command failed: /usr/sbin/sound_off.sh\n/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n"}}`

```auto

{"_msgid":"49ab6b798649273d","topic":"","payload":"/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n","rc":{"code":1,"message":"Command failed: /usr/sbin/sound_off.sh\n/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n"}}

```

```auto

{"_msgid":"49ab6b798649273d","topic":"","payload":{"code":1,"message":"Command failed: /usr/sbin/sound_off.sh\n/usr/sbin/sound_off.sh: line 2: kill: (2008) - No such process\n"}}

```

When I do run it in the linux terminal:

```auto
$ /usr/sbin/sound_off.sh
Command executed successfully
/usr/sbin/sound_off.sh: line 2: kill: (1995) - No such process

```

---

<div class="post-metadata">

**Author:** ![PeterSmarthome](https://avatars.discourse-cdn.com/v4/letter/p/50afbb/32.png) [@PeterSmarthome](https://discourse.nodered.org/u/PeterSmarthome)\
**Post date:** [17 November 2024 11:54 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126/45 "2024-11-17T11:54:02Z")

</div>

First of all thank you very much for the support ypou did provide to me!

So, here is my solution to the issue: I decided to use the http-request node and send the commands directly to the cloud API, instead of using exec-node to call the local smartthings script.

However, the local smartthings script turned out to be very useful in this approach, because you can call it in debug mode and you see all the RestAPI calls. In this way, I can get all my settings to the Samsung devices running manually in the smartthings scripts and copy everything into the http-request node.

To call the smartthings script in debug mode I use:  
`SMARTTHINGS_DEBUG=true /usr/bin/smartthings devices:commands <deviceID> --token=<authToken> 'main:execute:execute("/mode/vs/0",{"x.com.samsung.da.options":["Sound_Off"]})'`

In reply I get this information:  
`{"url":"https://api.smartthings.com/devices/ __deviceID__ /commands","method":"post","headers":{"Content-Type":"application/json;charset=utf-8","Accept":"application/json","User-Agent":"@smartthings/cli/1.10.2 linux-x64 node-v18.20.4","Accept-Language":"de-DE","Authorization":"Bearer __authTOKEN__"},"data":{"commands":[{"component":"main","capability":"execute","command":"execute","arguments":["/mode/vs/0",{"x.com.samsung.da.options":["Sound_Off"]}]}]}}`

And here is my flow, that I used to turn sound on and off:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f6fbd493a4ebfadb8caf971a3ac3e2f1581cbd34.png)

```auto
[
    {
        "id": "12d3080a2a78e624",
        "type": "inject",
        "z": "ba4e13d6eb48084d",
        "name": "Sound OFF",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"commands\":[{\"component\":\"main\",\"capability\":\"execute\",\"command\":\"execute\",\"arguments\":[\"/mode/vs/0\",{\"x.com.samsung.da.options\":[\"Sound_Off\"]}]}]}",
        "payloadType": "json",
        "x": 130,
        "y": 940,
        "wires": [
            [
                "21a430afc34454d6"
            ]
        ]
    },
    {
        "id": "21a430afc34454d6",
        "type": "http request",
        "z": "ba4e13d6eb48084d",
        "name": "",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "https://api.smartthings.com/devices/ __deviceID__ /commands",
        "tls": "4b9925bda87b4f12",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": true,
        "authType": "",
        "senderr": true,
        "headers": [
            {
                "keyType": "Content-Type",
                "keyValue": "",
                "valueType": "other",
                "valueValue": "application/json;charset=utf-8"
            },
            {
                "keyType": "Accept",
                "keyValue": "",
                "valueType": "other",
                "valueValue": "application/json"
            },
            {
                "keyType": "Accept-Language",
                "keyValue": "",
                "valueType": "other",
                "valueValue": "de-DE"
            },
            {
                "keyType": "Authorization",
                "keyValue": "",
                "valueType": "other",
                "valueValue": "Bearer __authToken__"
            }
        ],
        "x": 410,
        "y": 940,
        "wires": [
            [
                "560664932e24f093"
            ]
        ]
    },
    {
        "id": "560664932e24f093",
        "type": "debug",
        "z": "ba4e13d6eb48084d",
        "name": "http reply",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 640,
        "y": 940,
        "wires": []
    },
    {
        "id": "dc485cbc3331e2fd",
        "type": "inject",
        "z": "ba4e13d6eb48084d",
        "name": "Sound ON",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "{\"commands\":[{\"component\":\"main\",\"capability\":\"execute\",\"command\":\"execute\",\"arguments\":[\"/mode/vs/0\",{\"x.com.samsung.da.options\":[\"Sound_On\"]}]}]}",
        "payloadType": "json",
        "x": 120,
        "y": 1000,
        "wires": [
            [
                "21a430afc34454d6"
            ]
        ]
    },
    {
        "id": "4b9925bda87b4f12",
        "type": "tls-config",
        "name": "",
        "cert": "",
        "key": "",
        "ca": "",
        "certname": "",
        "keyname": "",
        "caname": "",
        "servername": "",
        "verifyservercert": true,
        "alpnprotocol": ""
    }
]

```

---

<div class="post-metadata">

**Author:** ![johnwalicki](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/johnwalicki/32/8848_2.png) [@johnwalicki](https://discourse.nodered.org/u/johnwalicki)\
**Post date:** [21 November 2024 20:24 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126/46 "2024-11-21T20:24:25Z")

</div>

I've been very successful with the [node-red-contrib-smartthings](https://flows.nodered.org/node/node-red-contrib-smartthings) node and have several home automations that are controlled through node-red-contrib-smartthings nodes.

---

<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:** [19 February 2025 20:24 UTC](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126/47 "2025-02-19T20:24:33Z")

</div>

Closed on 19 February 2025 20:24 UTC

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

[Previous page](https://discourse.nodered.org/t/exec-node-works-fine-in-linux-terminal-but-not-in-exec-node/93126.md?page=2)
