I'm trying to automate some things and get adb to connect to a list of devices. I'm using curl to retrieve a list of IP's but for the sake of simplicity I'm just using a simple file right now with the content being:
192.168.1.108
192.168.1.54
I have tried to execute
cat devices | xargs -L1 -t ./adb connect
which results in
/adb connect 192.168.1.108
:5555cted to 192.168.1.108
/adb connect 192.168.1.54
:5555cted to 192.168.1.54
and adb devices yields
List of devices attached
:555568.device
:555568.unauthorized
Which does not make any sense to me. If I manually enters the connect-commands, adb devices says
List of devices attached
192.168.1.108:5555 offline
192.168.1.54:5555 offline
:555568.device
:555568.unauthorized
which is more like what I would have expected (except for the two weird devices). To me it seems like the input (commands) are the same but the output is different but what causes the difference? I have also tried a simple "while read line do ... end" script which results in the same weird behavior.
Thanks,
I think the problem is most likely due to the presence of CRLF line terminators coming in from copy pasting text from a Windows machine. You can check that by doing
file devices
devices: ASCII text, with CRLF line terminators
You need to convert CRLF to LF, to do so you can run this command.
dos2unix devices