2

I am currently trying to run a simple shell script via MacroDroid. devices are Huawei and Samsung (Oreo not rooted).

in MacroDroid tried following locations:

/data/local/tmp/script.sh
/storage/emulated/0/MacroDroid/script.sh
/storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/script.sh

MacroDroid reports permission denied:

/system/bin/sh: <stdin>[4]: /data/local/tmp/script.sh: can't execute: Permission denied
/system/bin/sh: <stdin>[4]: /storage/emulated/0/MacroDroid/script.sh: can't execute: Permission denied
/system/bin/sh: <stdin>[4]: /storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/script.sh: can't execute: Permission denied

the script itself is working when running from adb shell:

adb shell
$ cd /data/local/tmp
$ chmod 0755 script.sh
$ ls -nZ script.sh
-rwxr-xr-x 1 2000 2000 u:object_r:shell_data_file:s0 ...
$ ./script.sh

In Terminal Emulator the script is readable (and passing as argument to sh works):

$ /data/local/tmp/script.sh
/system/bin/sh: /data/local/tmp/script.sh: not found
$ sh /data/local/tmp/script.sh
$ sh /storage/emulated/0/MacroDroid/script.sh
$ sh /storage/emulated/0/Android/data/com.arlosoft.macrodroid/files/script.sh

MacroDroid got all permissions granted in settings. Macros can create own log files in /storage/emulated/0

What is the proper location for shell scripts on non-rooted device?

0
1

Shell script Action is somewhat misleading in itself. It should be renamed as "Shell commands" instead. In the input area you are required to input the whole of your script actually. If you don't want that but wants to run an already made script instead, run it as

sh SCRIPT_PATH
sh /sdcard/my_script.sh     # example

This should work.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.