[英]Script file to run in android devices with help of the sh present in adb shell
I am facing a problem in writing a shell script for android devices to be run only on sh present in the device (/system/bin/sh). 我在为Android设备编写仅在设备(/ system / bin / sh)中的sh上运行的shell脚本时遇到问题。 I have written the following script 我写了以下脚本
#!/system/bin/sh
while [ 1 ]; do
cat /sys/kernel/debug/gpio > /dev/kmsg
sleep 2
done
If I run the shell by the below command it cant find the system/bin/sh root@xyz3g:/data # ./test_script.sh
/system/bin/sh: ./test_script.sh:
its giving No such file or directory 如果我通过以下命令运行shell,它将无法找到system/bin/sh root@xyz3g:/data # ./test_script.sh
/system/bin/sh: ./test_script.sh:
system/bin/sh root@xyz3g:/data # ./test_script.sh
/system/bin/sh: ./test_script.sh:
其给出的文件或目录不存在
What could be the possible reasons for the above error.? 发生上述错误的可能原因是什么?
So if I am running this script by following command then I am getting a syntax Error . 因此,如果我通过以下命令运行此脚本,那么我将得到语法Error。
test_script.sh[2]: syntax error: 'while' unmatched
I have confirmed the syntax but couldnt get any idea out of this.Can you please help me with this as I am an amateur in shell scripting. 我已经确认了语法,但对此一无所知。由于我是shell脚本的业余爱好者,请您帮我一下。
in regards of permissions and other applications
) if I run this script in rooted samsung devices and google released phones like NEXUS 4,NEXUS 5 除此之外,如果我在有根的三星设备和Google发布的手机(如NEXUS 4,NEXUS 5)中运行此脚本,是否可以知道是否存在差异( in regards of permissions and other applications
) Thanks in advance. 提前致谢。
Thanks Below steps worked for me 谢谢下面的步骤为我工作
Step1: Open file in notepad++ 步骤1:在记事本++中打开文件
Step2: Go To Edit-->EOL Conversion-->Unix/Osxformat 步骤2:转到“编辑”->“ EOL转换”-> Unix / Osxformat
Step3: Save it 第三步:保存
in windows end of line is CR+LF 在Windows的行尾是CR + LF
in android end of line is LF 在android行的末尾是LF
I guess you edit the file in windows 我猜你在Windows中编辑文件
change it to unix style may solve the problem 将其更改为Unix样式可能会解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.