Android: run a script on non-rooted device

19,760

Solution 1

Oh, I can run my script without SU permission, just use sh command:

$ cd /sdcard
$ sh helloworld.sh
hello world

I think we cannot do the same with a binary executable file.

Solution 2

On non-rooted device you can run a script on SDcard with sh command:

    adb shell sh path_to_script_on_sdcard/script.sh
Share:
19,760
Khang .NT
Author by

Khang .NT

Coding is not only my job, it's my life! I look forward to everyone's support, and hope to help another solve the problem. We learn - we share.

Updated on June 19, 2022

Comments

  • Khang .NT
    Khang .NT almost 2 years

    Can I run my binary executable file or script bash file on a non-rooted device? I have a small script like this:

    #helloworld.sh
    echo "hello world"
    

    I saved it in /sdcard and try to run, but i got "Permission denied". I have researched, the reason is Execute permissions on the SDCard is blocked.

    Is it possible to run? How can I do that without SU command? I think it is very helpful if somehow can execute any script file.