The experience of Shell scripting in development

Source: Internet
Author: User

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

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.