public
Last active

Computer Availability Map logout script

  • Download Gist
logout.pl
Perl
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#!/usr/bin/perl -w
 
use LWP;
use Sys::Hostname;
 
my $host = hostname();
#the hostname after which you can find out the IP address
my $ipaddr = inet_ntoa(scalar gethostbyname($host || 'localhost'));
 
$ua = LWP::UserAgent->new;
#timeout in 60 seconds if we can't make a connection
$ua->timeout(60);
 
#send the HTTP request with the status of 0 and computer name and the host
$request = $ua->post('http://yourdomain.edu/statuschange.php',
["status" => "0",
"workstation" => $ipaddr,
"host" => $host]);
 
#if successful log 200 status else quit and log error
if ($request->is_success) {
$content = $request->content;
print "Content-type: text/html\\n\\n";
print $content;
} else {
die "Can't get to URL", $request->status_line;
}
exit;

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.