【发布时间】:2018-11-21 06:01:46
【问题描述】:
我正在编写一个 bin bash shell 脚本来一次从多个设备收集信息。但是我注意到如果在 while 循环中执行任何 adb 命令会破坏它。不知道为什么,因为循环显然不完整。我知道有多个提要讨论这个话题,但我找不到像我这样的类似问题。任何建议都会有所帮助。谢谢。
#!/bin/bash
echo "# Collecting attached devices under adb and record the project name..."
adb devices | while read line
do
if [ "$line" != "" ] && [ `echo $line | awk '{print $2}'` = "device" ]
then
device_sn=`echo $line | awk '{print $1}'`
project_name=`adb -s $device_sn shell getprop ro.product.device` #This line will break the while loop. If I remove it I can have all connected devices reboot to bootloader
echo "$project_name: $device_sn is rebooting to bootloader"
adb -s $device_sn reboot bootloader
fi
done
【问题讨论】: