Skip to content Skip to sidebar Skip to footer

Perl Script To Store Device Serial Number And Install Apk Using Adb

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

Solution 1:

Here is an example of just the adb devices command using IPC::Run3:

use strict;
use warnings qw(all);

use IPC::Run3;
use Carp qw(croak confess cluck);
use Data::Dumper;

my $ADB_PATH = '/path/to/adb';  # EDIT THISmy @devices = get_devices();
print Dumper(\@devices);
exit0;

# subssubget_devices{
    my $adb_out;
    run3 [$ADB_PATH, 'devices'], undef, \$adb_out, undef;
    $? and cluck "Warning: non-zero exit status from adb ($?)";

    my @res = $adb_out =~ m/^([[:xdigit:]]+) \s+ device$/xmg;
    returnwantarray ? @res : \@res;
}

For a lot of this, you may be able to use qx/`` as well. E.g., you could replace the run3 with my $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.)

Post a Comment for "Perl Script To Store Device Serial Number And Install Apk Using Adb"