The experience of Shell scripting in development
This period of time in the development of a program, program output has a lot of logs. Sometimes you need to log to analyze the problem of the error. Separate viewing efficiency is too low to analyze anything. So I thought of the shell. Log files are on Android's phone!
Development environment Fedora, MacOS.
Mobile phone NEXUS4,NEXUS5.
development tool VIM + ARM-GCC.
Scenario 1
Some bin programs need to be added to the phone, but one is too cumbersome to add:
#!/bin/shfor i in $ (seq);d oadb push "STREAM_" $i/data/local/tmpdone;
This code can process a batch of data files beginning with STREAM_ and add them to the phone
Scenario 2
Start the bin program of your phone via ADB. My side because of the socket port problem, need to be the bin program, completely exited after the normal start.
Each time it is an operation such as ADB Shell;ps;kill. However, it is convenient to use the script.
#!/bin/sha= ' adb shell ' PS | grep stream "' echo $apid = ' echo $a | Cut-d ""-F 2 ' echo $pidadb shell "kill ${pid}" adb push stream_3/data/local/tmpadb Shell/data/local/tmp/stream_3
The script will be processed automatically if it detects that the program is still running, kill Point, and then start
Scenario 3
Analyze the log. The log file is in the SD card of the phone.
While the program is running, I need to check the status of the operation.
#!/bin/shwhile true;doadb pull/sdcard/log. Tail-n Logdone
The script will remove the file from the SD card of the phone into a directory, and then output the last 10 lines.
Scenario 4
Monitor a file in your phone's SD card
#!/bin/shwhile true;doadb Shell "DF | grep emulated "adb shell" ls/sdcard/-L | grep stream.mp4 "adb shell" ls/sdcard/-L | grep log "sleep 1;done;
The experience of Shell scripting in development