简体   繁体   中英

Unable to execute a shell script in android shell

I am trying tun a shell script from android 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. The result is same. I verified from mount command that both the partitions are not mounted with noexec flag.

I am able to get it working with sh run_script but I want to get it working by executing directly.

Usually this happens when a shebang is not correct. 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. cat command ,can not see it. use vi,we can see

!/bin/sh^M

ps^M

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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