using Net::Telnet to test a http server
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 So, I assume, if I can catch , 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. Thanks, kapot __ 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]
Re: using Net::Telnet to test a http server
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 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 > > > > So, I assume, if I can catch , 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]
Problem installing Device::SerialPort 0.12 perl module on RedHat 8.0
Hi, I freshly installed RedHat 8.0, but I cant install your Device::SerialPort version 0.12. When I run perl Makefile.PL, I got this error : Finding ioctl methods ... trying 'termios.ph'... nope trying 'asm/termios.ph'... not useful trying 'sys/termiox.ph'... nope trying 'sys/termios.ph'... not useful trying 'sys/ttycom.ph'... nope Device::Serial could not find ioctl definitions! I got an instruction to do this : cd /usr/include; h2ph -r -l . But, it stopped like this : ./asm/string.h -> ./asm/string.ph ./asm/string-486.h -> ./asm/string-486.ph Cannot parse: "repnz; scasb Then I tried to h2ph manually for /usr/include/asm/termios.h I run : cd /usr/include/asm; h2ph -r -l termios.h cd /usr/include/sys; h2ph -r -l . And I can found all the .ph required on my machine : # find / -name "term*.ph" /usr/lib/perl5/5.8.0/i386-linux-thread-multi/bits/termios.ph /usr/lib/perl5/5.8.0/i386-linux-thread-multi/linux/termios.ph /usr/lib/perl5/5.8.0/i386-linux-thread-multi/sys/termios.ph /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/termios.ph /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/sys/termios.ph /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/asm/termios.ph But, again, no luck. Any ideas what should I do next ? I can install this module in RedHat 7.3. Thanks, __ 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]
module for IP calculation.
Hi, Is there any ready to use perl module for IP address calculation? For example: I have an IP Address and Netmask, then I need to calculate the broadcast and network. Thanks, kapot __ 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]
modifying xml entry
Hi, I have a XML file like this : password dccftp 22 127.0.0.1 1234567890 Could you give me a working perl code to modify the entries? user will input from keyboard : FTPServer Username = Password = Port Number = DCCBox IPAddress = Serial = After this, it will modify that config.xml entry. I tried to learn XML::Parser, but still I dont understand how to implement this. Thanks. __ 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]
RE: modifying xml entry
Well, of course I dont ask the complete working code ... English is not my mother language, so maybe my writing was wrong, but I dont mean that I asked the complete working code. Hmm ... I dont understand about 'hash' variable type in perl, could you give me any 'example' ? thanks --- "Beau E. Cox" <[EMAIL PROTECTED]> wrote: > Hi - > > >Could you give me a working perl code to modify the entries? ... > > Sorry - that's not the way this list works :) > How can you learn if we spoon-feed you? > > We are more than happy to give you suggestions and point you > in productive directions. Then, you write the code. If you > still have problems, then post snippets of your code and > we will continue to help. > > OK, that said, here are my suggestions: > > Look at XML::Simple on CPAN. This module loads an XML file > into a hash (you probably should use forcearray => 1). You > may then modify that hash based upon user input. Finally, > print the hash to your output. > > Aloha => Beau. > > -Original Message- > From: Admin-Stress [mailto:[EMAIL PROTECTED]] > Sent: Monday, December 09, 2002 12:09 AM > To: perl > Subject: modifying xml entry > > > Hi, > I have a XML file like this : > > > >password >dccftp >22 > > >127.0.0.1 >1234567890 > > > > Could you give me a working perl code to modify the entries? user will input > from keyboard : > > FTPServer > Username = > Password = > Port Number = > > DCCBox > IPAddress = > Serial = > > After this, it will modify that config.xml entry. > > I tried to learn XML::Parser, but still I dont understand how to implement > this. > > Thanks. __ 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]
perl module for linux server IP address configuration
Hi, Just wondering is there any perl module for configuring linux server IP address? Thanks, __ 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]
accessing com port
Hi, Anyone know which perl module can be used for COM Port communication? I have a device that need to be accessed via COM1 for example. It can be tested using HyperTerminal in Windows. If connected, it will give 'a prompt' then I need to type 'some commands' and the device will return something. Is there any ready to use perl module for this? I searched in CPAN with keyword 'com' but I found no decent result (at least in my understanding). Thanks, __ 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]
tailing a text file
Hi, Anyone have the fastest and efficien way to tail a text file ? suppose I have a text file "example.txt" and I want to print the last X lines. Thanks. __ 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]
Catching unknown socket (or unknown handle / filehandle)
Hi, In this example, to 'catch' if the socket could not be created, by using -> or die ""; #!/usr/bin/perl -w use IO::Socket; $remote = IO::Socket::INET->new( Proto=> "tcp", PeerAddr => "localhost", PeerPort => "daytime(13)", ) or die "cannot connect to daytime port at localhost"; How can I use 'if' statement? So I can handle the exception better. $remote = IO::Socket::INET->new( Proto=> "tcp", PeerAddr => "localhost", PeerPort => "daytime(13)", ); if (...) { cleanup(); print "socket error"; exit(0); } I dont know how to check if a handle has not ben created. Anyone can explain to me? Thanks, pot __ 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]
checking parameters ...
I wrote a simple script like this : #!/usr/bin/perl if (($ARGV[0] eq "") && ($ARGV[1] eq "") && ($ARGV[2] eg "")) { print "You must give me 3 parameters\n"; exit; } Then, I tested like with 1 .. OR 2 ... OR 3 parameters, it did not print the text "You must...". Why this happened? How to detect "null" parameters? is "" equal to "null"? I can use "if (scalar(@ARGV) < 3) {...}" but that not the case. Thanks for help me to explain this. newbie __ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How to catch a string in parameters?
I want to make a script to print parameter-1, parameter-2, and parameter-3. Parameter-1 and parameter-2 just a SINGLE word. Parameter-3 = string. #!/usr/bin/perl $p1=$ARGV[0]; $p2=$ARGV[1]; $p3=$ARGV[2]; print "$p1 $p2 $p3" Then, I test it like this: ./myscript word word "this is string" But I got output: word word this How to catch a string? I use "" Thanks, __ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
module for manipulating text file
Hi, Anyone know which module should I use to manipulate text file (like /etc/passwd for example). I meant, to read a line, search a string, deleting a line, etc. My objective is to manage /etc/passwd via perl script (later via web interface). Right now, I can create a user by calling 'useradd', deleting a user by calling 'userdel', but I cant change password ... cant search a user. Thanks, __ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
module for manipulating text file
Hi, Anyone know which module should I use to manipulate text file (like /etc/passwd for example). I meant, to read a line, search a string, deleting a line, etc. My objective is to manage /etc/passwd via perl script (later via web interface). Right now, I can create a user by calling 'useradd', deleting a user by calling 'userdel', but I cant change password ... cant search a user. Thanks, __ Do you Yahoo!? New DSL Internet Access from SBC & Yahoo! http://sbc.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
consume CPU process
Hi, Anyone can give me example of simple script that can consume cpu resources at certain level? ./consumecpu 50 Then, it will consume 50% of cpu process. I need this script to stress test my machine. Is there any way to do this on perl? I cant figure it out. Thanks, kapot __ Do you Yahoo!? Faith Hill - Exclusive Performances, Videos & More http://faith.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
XML module
Hi, anyone can suggest me XML module for reading/parsing/modifying an XML file? Thanks, kapot __ Do you Yahoo!? Y! Web Hosting - Let the expert host your web site http://webhosting.yahoo.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]