Reputation: 31
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 regards of permissions and other applications
) if I run this script in rooted samsung devices and google released phones like NEXUS 4,NEXUS 5Thanks in advance.
Upvotes: 1
Views: 5379
Reputation: 61
Thanks Below steps worked for me
Step1: Open file in notepad++
Step2: Go To Edit-->EOL Conversion-->Unix/Osxformat
Step3: Save it
Upvotes: 5
Reputation: 11
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
Upvotes: 1