How to run a script from an app?

Hi all!
I have a script that enables my CAN drivers. This is the script:
#!/bin/sh

drv=“can_iot.ko”
kmod unload $drv

** # Output 1 to IoT slot 0 GPIO2**
** echo 7 > /sys/class/gpio/export**
** echo out > /sys/class/gpio/gpio7/direction**
** echo 1 > /sys/class/gpio/gpio7/value **
** # Route SPI to IoT slot 1**
** mux 5**
** # Reset IoT slot 1**
** mux 16**

# Bring driver back & iproute2 add in CAN
kmod load $drv
ip link set can0 type can bitrate 125000 triple-sampling on
ifconfig can0 up

This script works well when I launch it throug ./start_can.sh in /home/root of my mangOH (I put it in this folder through scp command).
At this point I want that it is lounched through an application. So I wrote this code:


in .adef:
image
But it doesn’t work! Also mux commands don’t work beside I added the muxctrl.api (in therminal they work).
Have I to do something other? For my project I don’t want to make script manual run but auto
Any help will be appreciated

You can use unsandboxed application with system() API to call the script.

you can see here:

I understand that the system command is sufficient to run a script?

:dizzy_face:

Have you tried that yet?

yes but I obtain this error log:


The same script works well when I launch it with ./start_can.sh

In your opinion have I to include something other? It’s strange that it can’t see mux, ifconfig, etc, I included these commands in the various .adef. On the other hand, if it hadn’t, this script wouldn’t have worked with the ./start_can.sh command on the terminal either.
sandboxed must be true or not? (in your code is false, but in this way it doesn’t see file system)

It must be unsandboxed

okay…but I don’t understand why other commands are uncognized when I launch the script in this way :frowning:

Becos it needs to be run in unsandboxed environment

I am unsandboxed in a.adef

Then is it ok to run?

yes, but I have errors in mux, ip and ifconfig commands. I can run correctly the script through the command ./start_can.sh on the shell

I have to export some path in the script?

you need to use full path in the script.

you can see here:

I solved!
As always, everything on this board is always complicated! There is not even the linux whereis command, so I had to look for the commands one by one where they were. On average they are all in the linked / systems / current folder. Thanks for your attention, another problem solved :grin:.
However, the best procedure is yours, simply by running the script with the systems command! Great!