# Bash command not found

**URL:** <https://discourse.nodered.org/t/bash-command-not-found/37048>\
**Category:** General\
**Created:** [5 December 2020 12:45 UTC](https://discourse.nodered.org/t/bash-command-not-found/37048 "2020-12-05T12:45:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [5 December 2020 12:45 UTC](https://discourse.nodered.org/t/bash-command-not-found/37048/1 "2020-12-05T12:45:36Z")

</div>

hello  
i have found this flow, which scan a network, the output is just empty so i added a second msg.payload where i got a error  
/bin/bash: sudo: command not found

my node Red is in a Containers on my pi itself it would work

```auto
[{"id":"c3961d41.0f858","type":"tab","label":"Scan Subnet for Devices","disabled":false,"info":""},{"id":"842fa7ed.314678","type":"inject","z":"c3961d41.0f858","name":"","props":[{"p":"payload","v":"","vt":"date"},{"p":"topic","v":"","vt":"string"}],"repeat":"60","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":150,"y":60,"wires":[["c43bcf07.4070d"]]},{"id":"c43bcf07.4070d","type":"exec","z":"c3961d41.0f858","command":"sudo nmap -sn 10.18.42.0/24 | awk '/Nmap scan report for/{printf $5;}/MAC Address:/{print \"|\"substr($0, index($0,$3)) }' | sort","addpay":false,"append":"","useSpawn":"false","timer":"","oldrc":false,"name":"scan subnet","x":370,"y":60,"wires":[["6903a852.c6bd58"],["65f5cef1.0da3c"],[]]},{"id":"6903a852.c6bd58","type":"function","z":"c3961d41.0f858","name":"Subnet Devices Array","func":"let response = msg.payload.split('\\n');\nlet found = []\nlet device\nresponse.forEach ( line => {\n if ( line.indexOf('|') > -1 ){\n device = {\n ip : line.split('| ')[0],\n mac: line.split('|')[1].split(' ')[0],\n brand: line.split('|')[1].split(' ')[1]\n }\n found.push ( device )\n }\n})\nmsg.payload = found;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":600,"y":60,"wires":[["c5c606d2.36a7f8"]]},{"id":"c5c606d2.36a7f8","type":"debug","z":"c3961d41.0f858","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":850,"y":60,"wires":[]},{"id":"65f5cef1.0da3c","type":"debug","z":"c3961d41.0f858","name":"test Output","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":860,"y":220,"wires":[]}]

```

---

<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:** [5 December 2020 13:37 UTC](https://discourse.nodered.org/t/bash-command-not-found/37048/2 "2020-12-05T13:37:33Z")

</div>

What does a debug node connected to the Exec node show?

> [@vikozo](#):
>
> `sudo nmap -sn 10.18.42.0/24`

I see the exec node runs that command. If you run it in a terminal does it work and do you need to enter a password?

---

<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:** [5 December 2020 14:49 UTC](https://discourse.nodered.org/t/bash-command-not-found/37048/3 "2020-12-05T14:49:43Z")

</div>

unless you have sudo and nmap installed inside your container then it is always going to fail.  
(and indeed the whole point of containers is to stop people running system level commands that could damage the rest of the system) - so either you need to install them inside your container (which even then would only scan the network inside the container) - or give it extra privileges to see out of the container. But realistically if you are trying to run things like nmap then you don't want to do it from within a container.

---

<div class="post-metadata">

**Author:** ![vikozo](https://avatars.discourse-cdn.com/v4/letter/v/858c86/32.png) [@vikozo](https://discourse.nodered.org/u/vikozo)\
**Post date:** [5 December 2020 16:11 UTC](https://discourse.nodered.org/t/bash-command-not-found/37048/4 "2020-12-05T16:11:43Z")

</div>

@dceejay  
yes you are correct - this is the problem there is no nmap or Sudo insight the container.  
Would have been a nice way to check the network for new device

have a nice day  
vinc

---

<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:** [3 February 2021 16:11 UTC](https://discourse.nodered.org/t/bash-command-not-found/37048/5 "2021-02-03T16:11:43Z")

</div>

Closed on 3 February 2021 16:11 UTC

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