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"); }
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |