Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LWP

Status
Not open for further replies.

fmuquartet

Programmer
Sep 21, 2006
60
US
Please observer the script below that monitors my remote Apaches. I am having a problem modifying the script for two new authentication mechanism that were put in place.

1) I need to script to specify a proxy server (no userid or passwd required).

2) When prompt for authentication dialog box enter specific account information (userid/passwd combo).

Thanks in advance!

#!/usr/bin/perl
# script: monitor

use LWP::Simple;
use constant URL => '<A HREF="use constant APACHECTL => '/usr/sbin/apachectl';
$MAIL = '/usr/sbin/sendmail';
$MAIL_FLAGS = '-t -oi';
$WEBMASTER = 'mark@yahoo.com';

head(URL) || resurrect();

sub resurrect {
open (STDOUT,"| $MAIL $MAIL_FLAGS") || die "mail: $!";
select STDOUT; $| = 1;
open (STDERR,">&STDOUT");

my $date = localtime();
print <<END;
To: $WEBMASTER
From: The Global PRD Web Server Monitor <nobody>
Subject: Web server is down

I tried to call the Web server at $date but there was
no answer. I am going to try to resurrect it now:

One moment while I apply magic-pixie dust!

END
;

system APACHECTL,'restart';

print <<END;

That's the best I could do. Hope it helped.

Worshipfully yours,

The Apache Server
END
close STDERR;
close STDOUT;
}
 
You will have to look into LWP or LWP::Simple can not handle this task.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
KevenADC--
I have 2 issues here: the document is protected as to why I need to enter LDAP account info when prompted, Secondly I need to specify the proxy for getting out to site.

I have made changes to my script to accommodate these requirements but still is not working as expected:

#!/usr/local/bin/perl
# script: webLazarus

use LWP::UserAgent;
$ua = new LWP::UserAgent;
#For Proxy
$ua->proxy(['http', 'ftp'] => '
#For protected Document
$req = new HTTP::Request GET => '$req->authorization_basic('userid', 'passwd');
print $ua->request($req)->as_string;

use LWP::Simple;
use constant URL => 'use constant APACHECTL => '/usr/sbin/apachectl';
$MAIL = '/usr/sbin/sendmail';
$MAIL_FLAGS = '-t -oi';
$WEBMASTER = 'foo@yahoo.com.com';

head(URL) || resurrect();

sub resurrect {
open (STDOUT,"| $MAIL $MAIL_FLAGS") || die "mail: $!";
select STDOUT; $| = 1;
open (STDERR,">&STDOUT");

my $date = localtime();
print <<END;

To: $WEBMASTER
From: The Watchful Web Server Monitor <nobody>
Subject: Web server is down

I tried to call the Web server at $date but there was
no answer. I am going to try to resurrect it now:

Mumble, mumble, mumble, shazzzzammmm!

END
;

system APACHECTL,'restart';

print <<END;

That's the best I could do. Hope it helped.

Worshipfully yours,

The Web Monitor
END
close STDERR;
close STDOUT;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top