From linuxwt at gmail.com Thu Nov 3 13:00:01 2011 From: linuxwt at gmail.com (Linuxwt Linuxwt) Date: Fri, 4 Nov 2011 04:00:01 +0800 Subject: [PerlChina] Welcome to the "China-pm" mailing list In-Reply-To: References: Message-ID: china-pm at pm.org 2011/11/4 > Welcome to the China-pm at pm.org mailing list! We have moved to Google > Group, 我们已经搬家啦 请访问 > http://groups.google.com/group/perlchina?hl=zh-cn > > To post to this list, send your message to: > > china-pm at pm.org > > General information about the mailing list is at: > > http://mail.pm.org/mailman/listinfo/china-pm > > If you ever want to unsubscribe or change your options (eg, switch to > or from digest mode, change your password, etc.), visit your > subscription page at: > > http://mail.pm.org/mailman/options/china-pm/linuxwt%40gmail.com > > You can also make such adjustments via email by sending a message to: > > China-pm-request at pm.org > > with the word `help' in the subject or body (don't include the > quotes), and you will get back a message with instructions. > > You must know your password to change your options (including changing > the password, itself) or to unsubscribe without confirmation. It is: > > 123.cc > > Normally, Mailman will remind you of your pm.org mailing list > passwords once every month, although you can disable this if you > prefer. This reminder will also include instructions on how to > unsubscribe or change your account options. There is also a button on > your options page that will email your current password to you. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From angelaxyu at hotmail.com Thu Nov 10 22:16:22 2011 From: angelaxyu at hotmail.com (Yu Gao) Date: Fri, 11 Nov 2011 14:16:22 +0800 Subject: [PerlChina] =?gb2312?b?cGVybLPM0PLH89b6?= Message-ID: 各位高手,来帮帮我吧. 最近为了工作方便,写了一小段perl,结果现在有如下问题: 程序的目的是 telnet 到设备上,执行相应命令,将返回值,记录到xxxx.log文件中. 问题: 1.若所有设备都在线,则工作一切正常.如果有一台设备不在线,则整个程序都停掉了,只会生成前面在线设备的日志. 2.若密码在没有修改的情况下,一切正常,改了密码就会停掉整个程序. 我现在需要解决的是 1.判断是否可以telnet,如果不可以,写产生相应无法telnet的日志. 2.判断telnet是否成功,如果不成功则产生相应日志后,继续执行下面的程序. 程序代码如下: #!/usr/bin/perl use 5.010; use Net::Telnet::Cisco; open (IPLIST,'<.\iplist.txt'); #iplist.txt是存放IP地址用的,格式为 1.1.1.1#2.2.2.2#3.3.3.3 $ip = ; @ips = split '#',$ip; foreach $slog(@ips) { my $session = Net::Telnet::Cisco->new(Host => $slog); $session->login('','password'); if($session->enable('enpassword')) { open(RZ,">$slog.log"); #用IP地址作为文件名,生成日志文件 @clo = $session->cmd('show clock'); @ver = $session->cmd('show ver'); @iib = $session->cmd('show ip int brief'); @log = $session->cmd('show logging'); print RZ "show clock \n\n @clo \n"; print RZ "show version \n\n @ver \n"; print RZ "show ip int brief \n\n @iib \n"; print RZ "show logging \n\n @log \n"; } else { warn "Can't enable: " . $session->errmsg; } $session->close; close RZ; } close IPLIST; 麻烦大家给瞧一瞧吧,谢谢了 -------------- next part -------------- An HTML attachment was scrubbed... URL: