# Run Binary, Commands and scripts from CLI and Boot scripts

**URL:** <https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068>\
**Category:** Installing and Using OpenWrt\
**Created:** [April 15, 2017, 12:26am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068 "2017-04-15T00:26:05Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 15, 2017, 12:26am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/1 "2017-04-15T00:26:06Z")

</div>

Hello,

I upgraded my router from an older compatible version. I have a compiled binary that I previously ran successfully from the Startup and Firewall Scripts. Also, I previously installed softflowd and ran 3 instances from the startup and firewall boot scripts.

I could also run these commands, binaries and shell scripts from the CLI.

Are there any suggestions, dependent packages, etc. I may need to install, or anything else that may be required to run binaries from the boot scripts and command line?

Thanks

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 15, 2017, 12:27am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/2 "2017-04-15T00:27:46Z")

</div>

This is the error I receive:

> root@LEDE:/etc/config# ./examplecommand  
> -ash: ./examplecommand: not found

---

<div class="post-metadata">

**Author:** ![stangri](https://forum.openwrt.org/user_avatar/forum.openwrt.org/stangri/32/58_2.png) [@stangri](https://forum.openwrt.org/u/stangri)\
**Post date:** [April 15, 2017, 1:02am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/3 "2017-04-15T01:02:05Z")

</div>

> [@lleachii](#):
>
> examplecommand

`ls -la /etc/config/examplecommand`

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 15, 2017, 6:09am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/4 "2017-04-15T06:09:12Z")

</div>

Stangri,

The command you posted shows the file information, so I assume you want to verify that I have set the file as executable.

> -rwxr-xr-x 1 root root 23895 Aug 14 2015 /etc/config/examplecommand

As I noted, this worked in a previous version by running:

> ./etc.config/examplecommand

In addition, I noted I'm experiencing issues with scrips, as well as an installed package named softflowd.

Thanks

---

<div class="post-metadata">

**Author:** ![tmomas](https://forum.openwrt.org/letter_avatar/tmomas/32/5_5575768a8748004e209b776fc1b2916d.png) [@tmomas](https://forum.openwrt.org/u/tmomas)\
**Post date:** [April 15, 2017, 7:00am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/5 "2017-04-15T07:00:18Z")

</div>

> [@lleachii](#):
>
> I upgraded my router from an older compatible version. I have a compiled binary

From which old to which new LEDE firmware did you upgrade?  
Where does that binary come from? When was is compiled?

The error message sounds like your binary has been compiled with a different musl version than the firmware image itself.

Do `make dirclean`, then compile the firmware image and your binary at the same time.

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 15, 2017, 7:29am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/6 "2017-04-15T07:29:32Z")

</div>

I upgraded from 14, to 15; and then from 15 to LEDE 17

The binary is ampr-ripd, it is a modified RIPv2 daemon that runs on a network to allow mesh nodes over the Internet for Amateur Radio Licensees.

It is written in C and I cross compiled it in version 14.0 days.

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 15, 2017, 7:42am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/7 "2017-04-15T07:42:27Z")

</div>

The developer of ampr-ripd (callsign: YO2LOJ), just informed me its only dependency is libc (which is installed).

---

<div class="post-metadata">

**Author:** ![tmomas](https://forum.openwrt.org/letter_avatar/tmomas/32/5_5575768a8748004e209b776fc1b2916d.png) [@tmomas](https://forum.openwrt.org/u/tmomas)\
**Post date:** [April 15, 2017, 8:47am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/8 "2017-04-15T08:47:35Z")

</div>

Which libc version?  
LEDE uses musl libc 1.1.16

---

<div class="post-metadata">

**Author:** ![Borromini](https://forum.openwrt.org/letter_avatar/borromini/32/5_5575768a8748004e209b776fc1b2916d.png) [@Borromini](https://forum.openwrt.org/u/Borromini)\
**Post date:** [April 15, 2017, 9:53am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/9 "2017-04-15T09:53:33Z")

</div>

Might be ash doesn't allow binaries to be run in the same dir. Try

`/bin/ash /path/to/your/binary`

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 15, 2017, 10:32am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/10 "2017-04-15T10:32:00Z")

</div>

root@LEDE:/etc/config# /bin/ash /etc/config/ampr-ripd  
/etc/config/ampr-ripd: line 1: syntax error: unexpected "("

root@LEDE:/etc/config# ./ampr-ripd  
ash: ./ampr-ripd: not found

---

<div class="post-metadata">

**Author:** ![hnyman](https://forum.openwrt.org/user_avatar/forum.openwrt.org/hnyman/32/19_2.png) [@hnyman](https://forum.openwrt.org/u/hnyman)\
**Post date:** [April 15, 2017, 10:33am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/11 "2017-04-15T10:33:15Z")

</div>

> [@lleachii](#):
>
> I upgraded from 14, to 15; and then from 15 to LEDE 17
> 
> The binary ... is written in C and I cross compiled it in version 14.0 days

Binaries compiled with older Openwrt or LEDE versions will cause that kind of error due to changed clib versions. Openwrt 14.07 and 15.05 still used uclibc while Openwrt DD trunk and LEDE use musl clib.

You need to cross compile the app again with the current toolchain.

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 15, 2017, 10:34am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/12 "2017-04-15T10:34:09Z")

</div>

I'll try that when I have an opportunity and inform the thread.

Thanks.

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 18, 2017, 10:47am UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/13 "2017-04-18T10:47:13Z")

</div>

I want to update you all (and ask if I should perhaps make a new thread for this).

After some time, and working with the developer, we had to add the following line to the in.c file:

`#define IPPORT_ROUTESERVER <number-is-here>`

Even after doing so, we receive this error:

> user@user:~/ampr-ripd-1.16.2$ mips-openwrt-linux-musl-gcc ampr-ripd.c  
> ampr-ripd.c: In function 'main':  
> ampr-ripd.c:1865:13: error: 'struct udphdr' has no member named 'dest'  
> (udh-\>dest == htons(IPPORT\_ROUTESERVER)) &&  
> ^  
> ampr-ripd.c:1866:13: error: 'struct udphdr' has no member named 'source'  
> (udh-\>source == htons(IPPORT\_ROUTESERVER)))  
> ^

Any idea?

Thanks

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 18, 2017, 3:11pm UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/14 "2017-04-18T15:11:39Z")

</div>

An update. I had success in compiling using the following command:

> mips-openwrt-linux-g++ ampr-ripd.c -v -Wwrite-strings -fpermissive

I now receive the following error:

> root@LEDE:/etc/config# ./ampr-ripd-1.16.2-MIPS  
> Error loading shared library libstdc++.so.6: No such file or directory (needed by ./ampr-ripd-1.16.2-MIPS)

I solved that by adding the package **_libstdcpp_**

But...my original problem still exists...I'm unable to run the file from the firewall/startup scripts. This is also the same behavior for a package I installed via **opkg** named **_softflowd_** (it also no longer runs form the scripts).

Any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![lleachii](https://forum.openwrt.org/letter_avatar/lleachii/32/5_5575768a8748004e209b776fc1b2916d.png) [@lleachii](https://forum.openwrt.org/u/lleachii)\
**Post date:** [April 18, 2017, 9:16pm UTC](https://forum.openwrt.org/t/run-binary-commands-and-scripts-from-cli-and-boot-scripts/3068/15 "2017-04-18T21:16:59Z")

</div>

Solved:

for the binary: I did /example instead of ./example (i also have to do that for any commands that may be specified within arguments in any executed command.

for the installed package: I now have to leave the process "Enabled" on the Process list. It does not appear to run any instances from the provided softflowd config script. In any case, I am now able to execute those instances.

Thanks All !
