Could anyone of you help me understanding this script as i have NO idea about Perl but i need the outcome of this script, also i would love to be able to translate it to PHP, as that's a language i understand and furtermore because i have all my other scripts for this particular project.
#!/usr/bin/perl
# upnp_tv_agent.pl
use warnings;
use strict;
use Net::UPnP::ControlPoint;
my $upnp = Net::UPnP::ControlPoint->new();
my @devs = $upnp->search();
my $tv;
foreach my $dev ( @devs )
{
foreach my $serv ( $dev->getservicelist() )
{
if ( $serv->getservicetype() =~ /TVAgent/ )
{
$tv = $serv;
last;
}
}
}
die "TVAgent not found\n" unless $tv;
my $res = action( 'GetCurrentMainTVChannel' );
print "[*] $res->{CurrentChannel}\n";
$res = action( 'GetWatchingInformation' );
print "[*] $res->{TVMode}\n";
print "[*] $res->{WatchingInformation}\n";
exit 0;
# -----------------------------------------------------------------------------
sub action
{
my ( $act, $args ) = @_;
my $r = $tv->postaction( $act, $args );
unless ( 200 == $r->getstatuscode() )
{
die "Error $act: ". $r->getstatuscode()."\n";
}
my $res = $r->getargumentlist();
unless ( 'OK' eq $res->{Result} )
{
die "Error $act response $res->{Result}\n";
}
return $res;
}
# -----------------------------------------------------------------------------
__END__
Thanks in advance for now.
Mathias Koch

New Topic/Question
Reply


MultiQuote






|