Created
December 11, 2012 04:41
-
-
Save myamamic/4255922 to your computer and use it in GitHub Desktop.
[Android][script] 端末が再起動しても、繰り返しadb logcatを実行する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# [概要] | |
# adb logcatを繰り返すスクリプト | |
# | |
# [使い方] | |
# 1. adb-choice-device.shと同じディレクトリに配置して下さい | |
# 2. ./Loop_adb_logcat.sh <ログファイルパス> | |
# 3. どの端末でlogcatを実行するか聞かれるので、指定して下さい | |
# | |
# [特徴] | |
# 端末が再起動したりadb接続が切断されても、 | |
# 再度adb接続されるのを待ち、自動でadb logcatします | |
# 引数の数が1つならOK | |
if [ $# -ne 1 ]; then | |
echo "引数を1つ指定してください。" 1>&2 | |
echo "引数はログファイルのパスです。" 1>&2 | |
exit 1 | |
fi | |
# このスクリプトのディレクトリパスを取得 | |
SHELL_DIR=`dirname $0` | |
# ctrl+cをトラップしたら、子プロセスを終了させるスクリプト | |
#source ${SHELL_DIR}/sig_handler.sh 2 | |
# 接続するデバイスのシリアル番号を取得するスクリプト | |
# このスクリプトの標準出力の最後に、デバイスIDが出力されます | |
source ${SHELL_DIR}/adb-choice-device.sh | tee temp_yama | |
DEVICE_ID=`tail -n 1 temp_yama` | |
rm temp_yama | |
while : | |
do | |
echo "---------------------------------------------" | |
adb -s ${DEVICE_ID} wait-for-device | |
date | tee -a $1 | |
adb -s ${DEVICE_ID} logcat -v threadtime *:v | tee -a $1 | |
echo "接続が切断されました。再度logcatします。" 1>&2 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
TODO
->ANDROID_SERIAL など定義済みの環境変数を使えばもっとすっきりできそう。