Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Here it goes much proper way to view: :)
open(OUTFILE, ">", "check_result.txt") or die ("unable to write output +: $!"); my @url = ('www.yahoo.com', 'www.google.com' ); #for check Ping & c +heck TCP #check Ping print OUTFILE "*Ping Result*\n"; use Net::Ping; $p = Net::Ping->new("syn"); if ($p->ping($url2[0])) { print OUTFILE "$url2[0] is alive. \n"; } else { print OUTFILE "$url2[0] is not alive. \n"; } if ($p->ping($url2[1])) { print OUTFILE "$url2[1] is alive. \n\n"; } else { print OUTFILE "$url2[1] is not alive. \n\n"; } #check TCP Result use strict; use Socket; use Time::HiRes qw( gettimeofday ); use Net::hostent; print OUTFILE "*TCP Result*\n"; my $timeout = 3; my $hostname = ($url2[0]); my $hostname1 = ($url2[1]); my $portnumber = '80'; my $portnumber1 = '80'; my $host = shift || $hostname; my $host1 = shift || $hostname1; my $port = shift || $portnumber; my $port1 = shift || $portnumber1; my $proto = getprotobyname('tcp'); my $iaddr = inet_aton($host); my $iaddr1 = inet_aton($host1); my $paddr = sockaddr_in($port, $iaddr); my $paddr1 = sockaddr_in($port1, $iaddr1); socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; +#for casino.sbobet.com eval { local $SIG{ALRM} = sub { die "timeout" }; alarm($timeout); connect(SOCKET, $paddr) || error(); alarm(0); }; if ($^P) { close SOCKET || die "close: $!"; print OUTFILE "$hostname is NOT listening on tcp port $portnumber.\n +"; } else { close SOCKET || die "close: $!"; print OUTFILE "$hostname is listening on tcp port $portnumber."; my ($t02, $t12, $startTime2); $startTime2 = gettimeofday(); connect(SOCK, $paddr); $t02 = gettimeofday() - $startTime2; close (SOCK); $t02 = gettimeofday() - $startTime2, printf OUTFILE (" avg:%.8f", $t02); print OUTFILE ("ms\n"); } socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!"; #f +or casino1.sbobet.com eval { local $SIG{ALRM} = sub { die "timeout" }; alarm($timeout); connect(SOCKET, $paddr1) || error(); alarm(0); }; if ($ARGV) { close SOCKET || die "close: $!"; print OUTFILE "$hostname1 is NOT listening on tcp port $portnumber1. +\n"; } else { close SOCKET || die "close: $!"; print OUTFILE "$hostname1 is listening on tcp port $portnumber1."; my ($t02, $t12, $startTime2); $startTime2 = gettimeofday(); connect(SOCK, $paddr1); $t02 = gettimeofday() - $startTime2; close (SOCK); $t02 = gettimeofday() - $startTime2, printf OUTFILE (" avg:%.8f", $t02); print OUTFILE ("ms"); }

In reply to Re^2: How to display the .pl process in command line by Anonymous Monk
in thread How to display the .pl process in command line by astronogun

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-03-19 04:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found