fPaste.me

A free, anonymous, minimalist and open source paste tool.


$VAR1 = undef
26-04-2021 07:59:49
Anonymous
sub run_cmd {
my ($self, $cmd, %args) = @_;
my %credentials = $self->get_ssh_credentials($args{domain});
delete $args{domain};
return $self->backend->run_ssh_cmd($cmd, %credentials, %args);
}

sub run_ssh_cmd {
my ($self, $cmd, %args) = @_;
my ($stdout, $stderr) = ('', '');
$args{wantarray} //= 0;
$args{keep_open} //= 1;
bmwqemu::log_call(cmd => $cmd, %{$self->hide_password(%args)});
my ($ssh, $chan) = $self->run_ssh($cmd, %args);
$chan->send_eof;

while (!$chan->eof) {
if (my ($o, $e) = $chan->read2) {
$stdout .= $o;
$stderr .= $e;
}
}
$stdout =~ s/^\s+|\s+$//g;

bmwqemu::diag("[run_ssh_cmd($cmd)] stdout:$/$stdout") if length($stdout);
bmwqemu::diag("[run_ssh_cmd($cmd)] stderr:$/$stderr") if length($stderr);
my $ret = $chan->exit_status();
bmwqemu::diag("[run_ssh_cmd($cmd)] exit-code: $ret");
$ssh->disconnect() unless ($args{keep_open});
print Dumper($stdout); # returns $VAR1 = '{10.1.1.22, 2620::2e:9dbc, fe80::a284}'

return $args{wantarray} ? ($ret, $stdout, $stderr) : $ret;
}


(undef, $ips_host_pov, $err) = console('svirt')->run_cmd(
'powershell -Command "Get-VM ' . $vmname . ' | Get-VMNetworkAdapter | Format-Table -HideTableHeaders IPAddresses"', wantarray => 1, keep_open => 0);

print "ips_host_pov returns \n";
print Dumper($ips_host_pov); # returns undef
print "$ips_host_pov";
#$ips_host_pov =~ m/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/;
#$ips_host_pov = $1;