小编use*_*001的帖子

借助 adb shell 中存在的 sh 在 android 设备中运行的脚本文件

我在为仅在设备 (/system/bin/sh) 中存在的 sh 上运行的 android 设备编写 shell 脚本时遇到问题。我写了以下脚本

#!/system/bin/sh

while [ 1 ]; do
   cat /sys/kernel/debug/gpio > /dev/kmsg
   sleep 2
done
Run Code Online (Sandbox Code Playgroud)

如果我通过以下命令运行 shell,它无法找到system/bin/sh root@xyz3g:/data # ./test_script.sh /system/bin/sh: ./test_script.sh:它给出的 No such file or directory

上述错误的可能原因是什么?

因此,如果我通过以下命令运行此脚本,则会收到语法错误。

test_script.sh[2]: syntax error: 'while' unmatched
Run Code Online (Sandbox Code Playgroud)

我已经确认了语法,但无法从中得到任何想法。你能帮我解决这个问题吗,因为我是 shell 脚本的业余爱好者。

  1. 除此之外,in regards of permissions and other applications如果我在有根的三星设备和谷歌发布的手机(如 NEXUS 4、NEXUS 5)中运行此脚本,我是否知道是否存在差异()

提前致谢。

linux bash shell android

1
推荐指数
1
解决办法
4047
查看次数

标签 统计

android ×1

bash ×1

linux ×1

shell ×1