[英]Exiting adb shell logcat inside a bash script
當我運行以下腳本時,它在中斷后掛起,因此從不執行“執行其他操作”。 我懷疑這是因為休息后,adb shell logcat仍在執行。 手動按ctrl-c會終止logcat並允許執行其他操作,但是有沒有辦法自動執行此操作?
adb logcat -c
adb shell logcat -s "test" | while IFS=" " read -a Array
do
echo "${Array[2]} ${Array[3]}"
if [ "${Array[2]}" == "${Array[3]}" ]
then echo "Equals"
break
fi
done
#do something else
謝謝
我最終使用的解決方案是以下內容的變體:
這有點舊,但是在遇到麻煩時偶然發現了這篇文章。
我發現正在發生的事情是,當您使用logcat傳遞while循環時,您正在對進程進行分組。 相反,您需要像這樣將logcat進程輸入到while循環中:
adb logcat -c
while IFS=" " read -a Array
do
echo "${Array[2]} ${Array[3]}"
if [ "${Array[2]}" == "${Array[3]}" ]
then echo "Equals"
break
fi
done < <(adb shell logcat -s "test")
我可能不太了解,但是這些頁面還提供了一些背景知識: http : //mywiki.wooledge.org/ProcessSubstitution https://askubuntu.com/questions/678915/whats-the-difference-between-撲朔迷離
logcat有一個選項“ -d”:轉儲日志,然后退出(不阻止)。
adb shell logcat -d -s "test"
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.