Rookie--shell script to solve the problem

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.