First, the implementation of the discovery of the ADB shell into the device and no longer continue to execute
/system/plugin/
....
Exit
All the online search is bat file call adb shell, no sh file call adb shell does not go down, look for other fruitless.
Finally, this method is used
1. txt
Enter the commands you want to run on your device in 1.txt to achieve your expectations.
Return ${res} in 1.txt, want to reference ${res} in parent script
WORKAROUND: Variable passing between the parent shell and the child shell
① if you want to invoke a variable in the parent shell in a child shell, export the variable in the parent shell.
#!/bin/bashexp8temp="Hello Shell"echo $exp 8temp
② if you want to invoke a variable in a child shell in the parent shell, there are a number of ways to refer to: http://blog.csdn.net/dreamcoding/article/details/8519689/
My situation is very special, is the equipment running parameters to use outside the device, the use of command replacement and named pipes do not work, using the intermediate file method can be resolved.
First put the parameters running on the device the device temporary file Tmp.txt, after exiting the script, pull Tmp.txt to local, and then local read res < Tmp.txt
ADB pull/system/plugin/< Temp.txt
Echo $res
Very stupid method, there should be a better way, is still in the rookie level, hope to progress a little every day, and then look back to see if there is no better solution.
Third, the command results exist in the file
res= ' ls | "$res" > temp.txt
Four, query to a process, and kill off
Id= ' PS | Grep"ABC"| Awk'{print $}'' echo $ID echo"---------------" forIdinch$ID DoKill-9$id Echo"killed $id"Done Echo"---------------"
Rookie--shell script to solve the problem