Hi, I have a list of around 150 servers to access. I need to write a telnet script to get the information from the nodes. I wrote a script which gets the IP address and tries to telnet to machine and gets the information. This script exits if suppose any of the server is un-accessible. Please have a look into this script and let me know how can I solve this.

use Net::Telnet(); print "count is $i\n"; open (OUT,">D:/PERL/TELNET_OUTPUT.txt") or die "could not open new +.txt\n"; open(FILE, "D:/PERL/ip.txt") || die "Failed\n"; foreach $x (<FILE>) { $telnet = Net::Telnet-> new(Host =>"$x",timeout =>13)or $telnet_er +r=1 ; if ($telnet_err){ print "Unable to telnet to $host machine\n";} $telnet -> login(root,siemens) or $login_err=1; if ($telnet->cmd("uname") == "Linux") { print OUT "\n<===========================>\n"; print OUT "\nWELCOME. You have Logged in to $x\n"; print OUT "\n----------------\n"; print OUT "Current Date: "; print OUT $telnet->cmd("date| tail -1"); print OUT "\n----------------\n"; print OUT "Serial Number of the Machine is: "; print OUT $telnet->cmd("dmidecode -t system | grep Serial"); print OUT "\n----------------\n"; print OUT "Operating System of the Machine is: "; print OUT $telnet->cmd("uname | tail -1"); print OUT "\n----------------\n"; print OUT "Host Name of the Machine is"; print OUT $telnet->cmd("hostname| tail -1"); print OUT "\n----------------\n"; print OUT " Disk Information of the Machine is"; print OUT $telnet->cmd("df -kh"); print OUT "\n-----------\n"; print OUT "IP Address of the Interfaces are : \n"; print OUT $telnet->cmd("/sbin/ifconfig -a | grep inet| cut -d\ +" \" -f2"); print OUT "\n-----------\n"; print OUT "MAC Address of the INterfaces are:\n"; print OUT $telnet->cmd("/sbin/ifconfig -a | grep ether"); }

In reply to Telnet Script exits if any of the machine is un-accessible by kumarnaveen

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.