# Exec failing to find tftp command in bash script

**URL:** <https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029>\
**Category:** General\
**Created:** [7 January 2020 23:18 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029 "2020-01-07T23:18:19Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![thorpebt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thorpebt/32/15906_2.png) [@thorpebt](https://discourse.nodered.org/u/thorpebt)\
**Post date:** [7 January 2020 23:18 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/1 "2020-01-07T23:18:19Z")

</div>

I have a script "getFiles.sh" containing the following:

```auto
ping -c 2 192.168.0.103
if [[$? == 0]];
then /usr/bin/tftp 192.168.0.103 -c get file1.json file2.json file3.json;
else exit 1;
fi

```

I have tftp-hpa installed on Ubuntu 18.04 (running node-red snap).

When I run this script in a terminal as my user account it works fine.  
When I call the script from an Exec node in node-red the pings work fine and then I get the following:

> code: 127  
> message: "Command failed: bash getFiles.sh↵getFiles.sh: line 6: /usr/bin/tftp: No such file or directory↵"

Any ideas would be appreciated..

Edit: Additional info - permissions set to 755 for tftp

```auto
-rwxr-xr-x 1 root root 31208 Mar 20 2017 tftp

```

---

<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:** [8 January 2020 00:26 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/2 "2020-01-08T00:26:18Z")

</div>

> [@thorpebt](#):
>
> permissions

There you have it. Only root user and members of root group have access to the command.

Change the group ownership to a more useful group like "wheel" and add the user you use to run Node-RED to that group.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [8 January 2020 09:46 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/3 "2020-01-08T09:46:53Z")

</div>

Likely not the issue: if you’re running node-red within snap, have you checked that you have access to this command from within your snap container? Try `which tftp` in an exec node.

The goal of Snap is to run programs in an isolated environment, meaning the node-red install has no access to other programs installed on your machine, not by default at least.

> **[A guide to snap permissions and interfaces | Ubuntu](https://ubuntu.com/blog/a-guide-to-snap-permissions-and-interfaces)**
>
> Snap is a Linux application package management system which allow developers to easily publish self contained software packages (snaps) that work across many distributions and versions of Linux. Snaps have security at their heart, and are designed to...

---

<div class="post-metadata">

**Author:** ![thorpebt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thorpebt/32/15906_2.png) [@thorpebt](https://discourse.nodered.org/u/thorpebt)\
**Post date:** [8 January 2020 14:38 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/4 "2020-01-08T14:38:21Z")

</div>

So `which tftp` in exec node fails.

> Command failed: which tftp

I'm new to snap, when trying to fix the issue yesterday I set the permissions as follows. None of these seem to indicate access to other applications or /usr/bin.  
 ![Screenshot from 2020-01-08 08-26-20](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/e/e911f45a477b50197d35b0d0ff46dbe697494156.png)

---

<div class="post-metadata">

**Author:** ![thorpebt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thorpebt/32/15906_2.png) [@thorpebt](https://discourse.nodered.org/u/thorpebt)\
**Post date:** [8 January 2020 14:42 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/5 "2020-01-08T14:42:05Z")

</div>

Node-red is being run by root user as far as I can tell. Therefore permissions should be acceptable.

```auto
brendan@ubuntu:~/$ ps -eF | grep node-red
root 965 1 0 1159 892 3 08:19 ? 00:00:00 /bin/sh /snap/node-red/533/bin/startNR
root 1254 965 0 232372 76356 2 08:19 ? 00:00:02 node-red
brendan 5945 3247 0 5383 1148 0 08:39 pts/0 00:00:00 grep --color=auto node-red

```

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [8 January 2020 14:52 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/6 "2020-01-08T14:52:02Z")

</div>

Yes correct, that’s exactly what snap is for: running completely sandboxed applications that can only interact with the host system to interfaces. Security is the primary goal of that, so allowing access to /usr/bin on the host comes with risks.

---

<div class="post-metadata">

**Author:** ![thorpebt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thorpebt/32/15906_2.png) [@thorpebt](https://discourse.nodered.org/u/thorpebt)\
**Post date:** [8 January 2020 14:53 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/7 "2020-01-08T14:53:15Z")

</div>

Understood, is it possible to install tftp-hpa within that sandbox?

If not I have no choice but to allow access to /usr/bin.. assuming that's possible.

---

<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:** [8 January 2020 15:40 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/8 "2020-01-08T15:40:17Z")

</div>

> [@thorpebt](#):
>
> If not I have no choice but to allow access to /usr/bin

Or you could remove the snap and install node-red using the [recommended install script](https://nodered.org/docs/getting-started/raspberrypi), which works for a Pi and Ubuntu.

---

<div class="post-metadata">

**Author:** ![thorpebt](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/thorpebt/32/15906_2.png) [@thorpebt](https://discourse.nodered.org/u/thorpebt)\
**Post date:** [8 January 2020 15:44 UTC](https://discourse.nodered.org/t/exec-failing-to-find-tftp-command-in-bash-script/20029/9 "2020-01-08T15:44:08Z")

</div>

Fair enough - thank you for the link.
