Launch a script as root through ADB

后端 未结 6 1037
眼角桃花
眼角桃花 2020-12-02 15:57

I have created a script to mount partitions and do some stuff in my Android system. I saved the script as install.sh in the /bin folder of Android.

I want to call th

6条回答
  •  Happy的楠姐
    2020-12-02 16:40

    This works :

    adb shell echo command which needs root privileges \| su
    

    If you need redirection:

    adb shell echo 'echo anytext > /data/data/aforbiddenfolder/file' \| su
    

    For "copying" a local file to an android path needing root privileges (but alocalfile must not contain '):

    cat alocalfile | adb shell echo "echo '`cat`' > /data/data/aforbiddenfolder/file" \| su
    

    If you have a better way (even for su versions which don't have -c), I am interested.

提交回复
热议问题