Bash script running ADB commands won't iterate through list of devices
<p>I have a simple bash script that iterates through a list of devices and runs adb shell commands to Android devices. The code is below:</p>

<pre><code>echo "Displaying devices to be configured:"
adb devices | sed "1d ; $ d"
echo ""
echo "###########################"
echo "#                         #"
echo "# Starting configuration! #"
echo "#                         #" 
echo "###########################"
echo ""

while read -r udid device usb product model device2; do

echo ""
echo $usb
echo ""

# INSTALL THE APPS
adb -s "$usb" install ./src/apps/1.apk
adb -s "$usb" install ./src/apps/quicksupport.apk

# SET WIFI OFF
adb -s "$usb" shell settings put global wifi_on 0

# SET SOUND TO 0
adb -s "$usb" shell service call audio 7 i32 3 i32 0 i32 1

# SET AUTO TIME ZONE OFF
adb -s "$usb" shell settings put global auto_time_zone 0

# SET INSTALL NON MARKET APPS ON
adb -s "$usb" shell settings put global install_non_market_apps 1

# REBOOT
adb -s "$usb" reboot

done &lt; &lt;(adb devices -l | sed "1d; $ d")

echo ""
echo "###########################"
echo "#                         #"
echo "# Configuration complete! #"
echo "#                         #" 
echo "###########################"
echo ""
</code></pre>

<p>When ran, the code will successfully run all configurations on one device. When plugged into two devices, the output reads as follows:</p>

<pre><code>Displaying devices to be configured:
0123456789ABCDEF    device
0123456789ABCDEF    device

###########################
#                         #
# Starting configuration! #
#                         #
###########################


usb:336592896X

[100%] /data/local/tmp/1.apk
    pkg: /data/local/tmp/1.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
[100%] /data/local/tmp/quicksupport.apk
    pkg: /data/local/tmp/quicksupport.apk
Failure [INSTALL_FAILED_ALREADY_EXISTS]
0123456789ABCDEF       device usb:337641472X product:msm8960 model:msm8960 device:msm8960
Result: Parcel(00000000    '....')

###########################
#                         #
# Configuration complete! #
#                         #
###########################
</code></pre>

<p>It seems to return the remainder of the <code>adb devices -l</code> command and than  break out of the loop. Is this an issue with bash? Is this an issue with adb? I've been trying to figure this out for days.</p>

<p>Note: The <code>Result: Parcel(00000000    '....')</code> output occurs directly after the sound is set to zero.</p>

<p>Note: Don't mind the <code>Failure [INSTALL_FAILED_ALREADY_EXISTS]</code>, that occurs because the apps are already installed. That's not what I'm concerned about.</p>

<p>Note: Posting <code>adb devices -l | hexdump -C</code></p>

<pre><code>00000000  4c 69 73 74 20 6f 66 20  64 65 76 69 63 65 73 20  |List of devices |
00000010  61 74 74 61 63 68 65 64  0a 30 31 32 33 34 35 36  |attached.0123456|
00000020  37 38 39 41 42 43 44 45  46 20 20 20 20 20 20 20  |789ABCDEF       |
00000030  64 65 76 69 63 65 20 75  73 62 3a 34 33 37 33 38  |device usb:43738|
00000040  37 32 36 34 58 20 70 72  6f 64 75 63 74 3a 6d 73  |7264X product:ms|
00000050  6d 38 39 36 30 20 6d 6f  64 65 6c 3a 6d 73 6d 38  |m8960 model:msm8|
00000060  39 36 30 20 64 65 76 69  63 65 3a 6d 73 6d 38 39  |960 device:msm89|
00000070  36 30 0a 30 31 32 33 34  35 36 37 38 39 41 42 43  |60.0123456789ABC|
00000080  44 45 46 20 20 20 20 20  20 20 64 65 76 69 63 65  |DEF       device|
00000090  20 75 73 62 3a 33 33 36  35 39 32 38 39 36 58 20  | usb:336592896X |
000000a0  70 72 6f 64 75 63 74 3a  6d 73 6d 38 39 36 30 20  |product:msm8960 |
000000b0  6d 6f 64 65 6c 3a 6d 73  6d 38 39 36 30 20 64 65  |model:msm8960 de|
000000c0  76 69 63 65 3a 6d 73 6d  38 39 36 30 0a 0a        |vice:msm8960..|
000000ce
</code></pre>