# Can’t execute cp command to a samba share using nodered

**URL:** <https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916>\
**Category:** General\
**Created:** [13 February 2021 05:16 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916 "2021-02-13T05:16:15Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielo515](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/danielo515/32/31899_2.png) [@danielo515](https://discourse.nodered.org/u/danielo515)\
**Post date:** [13 February 2021 05:16 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/1 "2021-02-13T05:16:15Z")

</div>

Hello.

I have a problem with a network share an the node-red integration, particularly the exec command.  
The command is a very simple copy one:

`cp /config/www/cam_captures/ojo_interior.jpg /config/samba/camera/1613148935618.jpg`

That is the string that I generate and I pass down to the exec command. If I copy paste that command on the shell it works perfectly, but If I execute the flow it does nothing. No error, the output status is 0, but the file is not copied.  
What can be going on here?

The flow is simple as hell:

```auto

[
    {
        "id": "a03ab777.710698",
        "type": "debug",
        "z": "f92c309a.afade",
        "name": "hook",
        "active": false,
        "tosidebar": true,
        "console": true,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 930,
        "y": 620,
        "wires": []
    },
    {
        "id": "271f9e23.20b8d2",
        "type": "exec",
        "z": "f92c309a.afade",
        "command": "",
        "addpay": true,
        "append": "",
        "useSpawn": "false",
        "timer": "",
        "oldrc": false,
        "name": "",
        "x": 710,
        "y": 720,
        "wires": [
            [],
            [],
            []
        ]
    },
    {
        "id": "9eeb7fdc.b058e",
        "type": "function",
        "z": "f92c309a.afade",
        "name": "build cmd",
        "func": "const file = msg.file\nconst share = '/config/samba/camera'\nconst d = new Date()\nmsg.payload = `cp ${file} ${share}/${Date.now()}.jpg`\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "x": 720,
        "y": 680,
        "wires": [
            [
                "271f9e23.20b8d2",
                "efc2f381.93dd3"
            ]
        ]
    },
    {
        "id": "efc2f381.93dd3",
        "type": "debug",
        "z": "f92c309a.afade",
        "name": "exec",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 960,
        "y": 720,
        "wires": []
    }
]

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/8/a814a63c8538dc4eb687191146b00737e2442954.png)

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [13 February 2021 05:51 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/2 "2021-02-13T05:51:18Z")

</div>

Whats the debug from the exec node have ?

you could try putting the output to a file from the linux side "\> output.txt"

---

<div class="post-metadata">

**Author:** ![danielo515](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/danielo515/32/31899_2.png) [@danielo515](https://discourse.nodered.org/u/danielo515)\
**Post date:** [13 February 2021 05:55 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/3 "2021-02-13T05:55:09Z")

</div>

The output, of all possible outputs is just status: 0, so everything is ok

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [13 February 2021 05:57 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/4 "2021-02-13T05:57:23Z")

</div>

send the output to a file just to be sure there isnt any output

have you tried running the command as sudo?

---

<div class="post-metadata">

**Author:** ![danielo515](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/danielo515/32/31899_2.png) [@danielo515](https://discourse.nodered.org/u/danielo515)\
**Post date:** [13 February 2021 06:09 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/5 "2021-02-13T06:09:05Z")

</div>

Do you mean to add sudo to the command?  
The command works on the console (where I run as root)

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [13 February 2021 06:13 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/6 "2021-02-13T06:13:22Z")

</div>

```auto
sudo cp /config/www/cam_captures/ojo_interior.jpg /config/samba/camera/1613148935618.jpg

```

I would say that its a permission problem.. what user is node-red running under?

---

<div class="post-metadata">

**Author:** ![danielo515](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/danielo515/32/31899_2.png) [@danielo515](https://discourse.nodered.org/u/danielo515)\
**Post date:** [13 February 2021 06:19 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/7 "2021-02-13T06:19:52Z")

</div>

I changed the output to be generated like this:

```auto

sudo cp /config/www/cam_captures/ojo_interior.jpg /config/samba/camera/1613197057497.jpg 2>/tmp/output.log

```

And I get an error 127  
I'll try the error redirect without sudo.  
But, if it were a permissions problem I should see some access denied error or something like that, no?

---

<div class="post-metadata">

**Author:** ![leftymuller](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/leftymuller/32/102326_2.png) [@leftymuller](https://discourse.nodered.org/u/leftymuller)\
**Post date:** [13 February 2021 06:23 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/8 "2021-02-13T06:23:06Z")

</div>

> [@danielo515](#):
>
> But, if it were a permissions problem I should see some access denied error or something like that, no?

Yep exactly.

---

<div class="post-metadata">

**Author:** ![danielo515](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/danielo515/32/31899_2.png) [@danielo515](https://discourse.nodered.org/u/danielo515)\
**Post date:** [13 February 2021 06:29 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/9 "2021-02-13T06:29:44Z")

</div>

Ok, I think I found the key problem.  
The node-red addon runs inside a docker container (this is how it works on hassio).  
If I inspect the container, I see it has the following volumes available:

```auto
            "Volumes": {
                "/config": {},
                "/data": {},
                "/dev": {},
                "/media": {},
                "/share": {},
                "/ssl": {}
            },

```

I guess the data is where the "data" is supposed to be mounted.  
To check if the problem is that the FS inside the docker container does, or does not, match the out one, I executed the following

```auto
docker exec -it addon_a0d7b954_nodered /bin/sh

```

There, I can check that the origing `/config` exists and contains all the data that I expect.  
The folder where the samba share is mounted, also exists, and guess what? All the files are there.  
My understanding is that the share is being mounted as a normal folder, and the data is being copied to the folder inside the container on the local FS, but outside the container what I see are the actual content of the share because it is mounted there.

---

<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:** [13 February 2021 12:41 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/10 "2021-02-13T12:41:40Z")

</div>

Note to everyone asking for help on the forum - please make sure that you give ALL of the relevant info.

In particular, we regularly see Docker causing additional confusion and complexity for people, it is key that you let people know the environment that you are using.

---

<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:** [14 April 2021 12:42 UTC](https://discourse.nodered.org/t/can-t-execute-cp-command-to-a-samba-share-using-nodered/40916/11 "2021-04-14T12:42:17Z")

</div>

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