Skip to content

Instantly share code, notes, and snippets.

@griggsk
Created November 29, 2010 19:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save griggsk/720479 to your computer and use it in GitHub Desktop.
Save griggsk/720479 to your computer and use it in GitHub Desktop.
Computer Availability Map login script
#!/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 1 and computer name
$request = $ua->post('http://yourdomain.edu/statuschange.php',
["status" => "1",
"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;
@mbah
Copy link

mbah commented Mar 6, 2012

I am almost writing the same login.pl code. And when I execute the login.pl, it will print the " Content-type: text/html\n\n" , but not the $content. Is there anything that I am doing wrong?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment