Hi David,

Thanks, I followed your suggestion, and it's working fine now.

About this test, what I need is to test the http server it self, not a website.

I meant, in one http server, can host more than one website (name based virtual 
hosting?).
So, if www.google.com and www.google.net in one http server, and accidently 
www.google.com
removed, but www.google.net still exist, my test to www.google.com will fail ... and 
the http
server is working fine.

That's why I prefer to use telnet port 80 for this purpose, by catching </html>

Any other idea?

Regards,
kapot

--- david <[EMAIL PROTECTED]> wrote:
> Admin-Stress wrote:
> 
> > Hi, I wrote a script to test if a http server is OK.
> > My method is :
> > - telnet to por 80
> > - send any text
> > 
> > If the http server is OK, it will return "some" text, and should contain
> > string </html>
> > 
> > So, I assume, if I can catch </html>, then my http server is OK.
> > 
> > Here is my perl script:
> > 
> >    use Net::Telnet;
> > 
> >    sub error {
> >      print -255;
> >      exit(0);
> >    }
> > 
> >    print "Testing http at $ARGV[0]\n";
> > 
> >    $telnet = new Net::Telnet ( Timeout=>30, Port=>80, Errmode=>error );
> >    $telnet->open($ARGV[0]);
> >    $telnet->print('TESTING');
> >    $telnet->waitfor('/<\/html>/');
> >    print 0;
> > 
> > The problem is, it always result -255 ... sub error called.
> > However, if I set Errmode=>'die', it will result 0.
> > 
> > Anyone know how to setup Errmode with a subroutine?
> > 
> > And, is my method good for testing http server? I just want as simple as
> > possible.
> > 
> 
> Have you try changing:
> 
> Erromode=>error
> 
> to:
> 
> Errormode=>\&error
> 
> this should do the trick. However, it sounds a little odd to use the Telnet 
> module to test a http server especially there are other modules that are 
> designed to work with the http protocal. will something like:
> 
> #!/usr/bin/perl -w
> use strict;
> 
> use LWP::UserAgent;
> 
> my $agent = LWP::UserAgent->new;
> my $req = HTTP::Request->new(HEAD => 'http://www.google.com');
> my $res = $agent->request($req);
> 
> if($res->is_success){
>         print "google up\n";
> }else{
>         print "google down?\n";
> }
> 
> __END__
> 
> make more sense?
> 
> david


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus – Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to