Skip to content

Instantly share code, notes, and snippets.

@sniper7kills
Created January 1, 2015 07:08
Show Gist options
  • Save sniper7kills/efe561b27a86cc5ca4e6 to your computer and use it in GitHub Desktop.
Save sniper7kills/efe561b27a86cc5ca4e6 to your computer and use it in GitHub Desktop.
VNC screen shot
#!/usr/bin/perl
use Net::VNC;
use TryCatch;
$|=true;
open(SERVERS , "results.csv");
while(<SERVERS>)
{
my ($host,$password) = split(/,/,$_);
$host =~ s/r//g;
$host =~ s/\R//g;
$host =~ s/n//g;
$password =~ s/r//g;
$password =~ s/n//g;
try
{
my $vnc;
eval
{
local $SIG{ALRM} = sub {die ""};
alarm 10;
#print $host;
$vnc = Net::VNC->new({hostname => $host, password => NULL});
$vnc->depth(24);
$vnc->login;
alarm 0;
#print $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";
alarm 30;
my $image = $vnc->capture;
$image->save("./screens/".$host.".png");
print $host . " -- " . $vnc->name . ": " . $vnc->width . ' x ' . $vnc->height . "\n";
alarm 0;
return true;
} or do {
#die $@ unless $@ eq "timeout\n" or $@ eq "resource not available\n";
alarm 0;
#warn $@;
}
}
catch
{
alarm 0;
#print "ERROR!\n";
}
}
close(SERVERS);
print "End of Loop\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment