简体   繁体   English

无法在Android Shell中执行Shell脚本

[英]Unable to execute a shell script in android shell

I am trying tun a shell script from android shell. 我正在尝试从android shell调整shell脚本。 Please see the output below. 请参见下面的输出。

root@user:/data # ./run_script.sh
/system/bin/sh: ./run_script.sh: No such file or directory

root@user:/data # ls -l run_script.sh
-rwxrwxrwx root     root         5861 2016-11-14 07:31 run_script.sh

Why is it saying "No such file or directory" The error is strange as the file is actually present. 为什么说“没有这样的文件或目录”,因为该文件实际存在,所以该错误很奇怪。

I tried copying the same shell script to /system partition as well. 我也尝试将相同的Shell脚本复制到/ system分区。 The result is same. 结果是一样的。 I verified from mount command that both the partitions are not mounted with noexec flag. 我从mount命令验证了两个分区都没有使用noexec标志安装。

I am able to get it working with sh run_script but I want to get it working by executing directly. 我可以使用sh run_script使它工作,但是我想直接执行使其工作。

Usually this happens when a shebang is not correct. 通常,这是在shebang不正确的情况下发生的。 Check if you have a "#!..." at the start of the script and remove it or correct it 检查脚本开头是否有“#!...”并将其删除或更正

file format reason maybe you create file in windows,then push it to phone. 文件格式的原因可能是您在Windows中创建文件,然后将其推送到手机。 cat command ,can not see it. cat命令,看不到它。 use vi,we can see 使用vi,我们可以看到

!/bin/sh^M !/ bin / sh ^ M

ps^M ps ^ M

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM