Created
January 1, 2015 07:08
-
-
Save sniper7kills/efe561b27a86cc5ca4e6 to your computer and use it in GitHub Desktop.
VNC screen shot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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