What I want to do is to capture the device serial numbers and store them in an array or list. Then I want to install my apk on various android devices that I connect to my system.I am trying to make a perl script that can do this for me.
Something like this:
if($ostype eq 'MSWin32') {
system("title Android");
$adbcommand_devices = "adb devices";
$adbcommand_install = "adb -s xxxxxxxx install HelloWorld.apk";
}
if(`adb -s xxxxxxxx get-state` =~ m/device/i) {
system($adbcommand_devices);
system($adbcommand_install);
}
else {
print "Device is offline\n";
}
The serial number should come from the currently connected device.
Here is an example of just the
adb devices
command usingIPC::Run3
:For a lot of this, you may be able to use
qx
/``
as well. E.g., you could replace therun3
withmy $adb_out = `$ADB_PATH devices`;
(because you didn't need to pass anything in to it, just out, and also didn't need to avoid the shell.)