Hi monks, I have a subroutine, in which user gives a server_list_array which containts the list of server ips. I then look through each server name, telnet and try to login. If it is a faliure, I make that line in server_list_array null(""). Later I can grep {\S}, @server_list_array to remove the failed servers. Am attaching the code, but the script dies when a server is encountered to which I cannot telnet, even though Errmode is set to 'return'. What is wrong here?
sub server_test_routine { for $i (0..$#SERVER_LIST_ARRAY) { $server_name = $SERVER_LIST_ARRAY[$i]; chomp($server_name); $server_status = 0; $server_test = Net::Telnet->new( Timeout => 10, Prompt => '/]/i', Host => $server_name, Errmode => 'return'); print "Server $server_name returned $server_test\n"; $server_status = $server_test->login(Name => $username,Passwor +d => $password,Errmode => 'return'); $server_test->close; if (!$server_status){ print "Rejecting server $server_name, cannot telnet\n"; $SERVER_LIST_ARRAY[$i] = ""; } } }

In reply to Testing for valid servers in Net::Telnet by tsk1979

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.