'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). 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
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 .
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.
- In addition to this , may I know if there is a difference(
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
Thanks in advance.
Solution 1:[1]
Thanks Below steps worked for me
Step1: Open file in notepad++
Step2: Go To Edit-->EOL Conversion-->Unix/Osxformat
Step3: Save it
Solution 2:[2]
in windows end of line is CR+LF
in android end of line is LF
I guess you edit the file in windows
change it to unix style may solve the problem
Solution 3:[3]
change the script_file dos2unix script_file
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Sonti Nagarjuna |
Solution 2 | straydog |
Solution 3 | Pendge |