# Is it possible to run a script from Docker Node-RED on host that opens in a bash windo?

**URL:** https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680
**Category:** General
**Tags:** docker
**Created:** [22 July 2024 19:12 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680 "2024-07-22T19:12:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Mastiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mastiff](https://discourse.nodered.org/u/Mastiff)
#### Post date: [22 July 2024 19:12 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/1 "2024-07-22T19:12:22Z")

</div>

I am using Screen via SSH to run a backup script on the host. The tricky thing is that I want a clean backup, so I'm stopping everything **including** Node-RED when doing it. I would like to be able to see on VNC if the script is still running, but that means that I need Screen to run the script in a window. I have tried to search around, but I haven't found an answer to that, probably because it's not a common use. The node is like this:

```auto
    {
        "id": "eb607f0925ac4680",
        "type": "inject",
        "z": "139a05b0e07293f9",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 100,
        "y": 400,
        "wires": [
            [
                "fab1883caac56ce6"
            ]
        ]
    },
    {
        "id": "fab1883caac56ce6",
        "type": "exec",
        "z": "139a05b0e07293f9",
        "command": "sshpass -p \"SECRET_PASSWORD\" ssh pi@192.168.5.2 -o StrictHostKeyChecking=no \"screen -S sikkerhetskopiering -d -m /home/pi/sikkerhetskopiering.sh\"",
        "addpay": "",
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "winHide": false,
        "oldrc": false,
        "name": "Backup via Screen",
        "x": 270,
        "y": 400,
        "wires": [
            [
                "e12ed03ace973a37"
            ],
            [
                "e12ed03ace973a37"
            ],
            [
                "e12ed03ace973a37"
            ]
        ]
    },
    {
        "id": "e12ed03ace973a37",
        "type": "debug",
        "z": "139a05b0e07293f9",
        "name": "debug 23",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 460,
        "y": 400,
        "wires": []
    }
]

```

So the SSH command is:

```auto
sshpass -p "SECRET_PASSWORD" ssh pi@192.168.5.2 -o StrictHostKeyChecking=no "screen -S sikkerhetskopiering -d -m /home/pi/sikkerhetskopiering.sh"

```

Is there a way to do what I want, or is that just not possible?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [22 July 2024 19:17 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/2 "2024-07-22T19:17:21Z")

</div>

If you are running screen on the remote device, you should be able to reconnect to the screen session from a different terminal. Have a look at the screen commands. Been a long time since I used it so I don't know the commands off the top of my head.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [22 July 2024 19:20 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/3 "2024-07-22T19:20:18Z")

</div>

I don't know if Docker makes a difference, but regarding running commands over ssh on another device:

Can't you tell that the script is still running because the exec node has not sent a message on it's return code output?

And if you set the exec node to send output while the command is running, you can see progress messages from your script.

---

<div class="post-metadata">

### Author: ![Mastiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mastiff](https://discourse.nodered.org/u/Mastiff)
#### Post date: [22 July 2024 19:29 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/4 "2024-07-22T19:29:06Z")

</div>

@TotallyInformation I have tried to find some way to do it, but it maybe over my head...

@jbudd Well, as I said, I am stopping everything with the script **including** Node-RED, so there is no node to receive the message.

---

<div class="post-metadata">

### Author: ![Mastiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mastiff](https://discourse.nodered.org/u/Mastiff)
#### Post date: [22 July 2024 19:44 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/5 "2024-07-22T19:44:49Z")

</div>

Oh, finally found it! I can use `screen -ls`, which will show me the running sessions as numbers, let's say it's 92358 and then `screen -r 92358` to connect to it!

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [22 July 2024 19:45 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/6 "2024-07-22T19:45:58Z")

</div>

But you are running the command from node red on a "separate" machine?

Oh you solved it. 😀

---

<div class="post-metadata">

### Author: ![Mastiff](https://avatars.discourse-cdn.com/v4/letter/m/ee7513/32.png) [@Mastiff](https://discourse.nodered.org/u/Mastiff)
#### Post date: [22 July 2024 20:01 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/7 "2024-07-22T20:01:14Z")

</div>

Yep, I did! 👍 But no, I'm running the command on the only Pi that I have in my car, so a Docker instance running on the host that runs the script. No other Pi's are connected to that network to send the command, and I'm automating a backup to a directory named after date and time every night at 04.30. The window is a safeguard if it stops on something I will be able to connect to it with VNC and see what's holding it up.

---

<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: [5 August 2024 20:01 UTC](https://discourse.nodered.org/t/is-it-possible-to-run-a-script-from-docker-node-red-on-host-that-opens-in-a-bash-windo/89680/8 "2024-08-05T20:01:17Z")

</div>

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