 |
|
Home:
Perl Programming Help:
Advanced:
Help with Telnet commands.:
Edit Log
|
|

cuboidgraphix
User
Jan 21, 2009, 2:15 PM
Views: 3821
|
|
Help with Telnet commands.
|
|
|
Hi again guys, Well I've still been trying on my own and I've recently ran into a snag with a script of mine... The code is as follows:
#!/usr/bin/perl # This file is the clear.pl # This is a script that will telnet into the BSM, # and clear all SWERR and erase all cleared alarms. use strict; use warnings; use Net::Telnet; use Text::ParseWords; use POSIX qw/strftime/; my $date = strftime("%Y-%m-%d", localtime(time)); my $temp = "/home/bsm/data/temp.txt"; my $user="USR"; my $pass="PWD"; my $server="HOST"; my $t = Net::Telnet->new($server); $t->waitfor('/login:/'); $t->print("$user"); $t->waitfor('/Password:/'); $t->print("$pass"); $t->waitfor('/%/'); $t->print("cliapp"); $t->waitfor('/>/'); $t->print("alarm;"); $t->waitfor('/FaultName/'); my ($data) = $t->waitfor('/>/'); open(WRITE, ">", "$temp") or die "Can't open 'temp.txt' $!"; print WRITE $data; close WRITE; my $file = $temp || die "Usage: $0 <filename>\n"; open my $FH, '<', $file or die "Can't open '$file' $!"; while (<$FH>) { if($_ =~ /^#/){ my (undef, $index, $status, $activity, $datetime, $source, $severity, $faultname) = quotewords('\s+', 0, $_); foreach($faultname =~ /SWERR/){ print $index, "\n"; print $faultname, "\n"; $t->waitfor('/>/'); ## REMOVED THIS LINE ## $t->print("cd $source;"); $t->waitfor('/>/'); $t->print("action uploadlogsfromcc1;"); $t->waitfor('/>/'); } } } $t->close; #system("/home/bsm/sendupdate.pl"); Now ... when I run this code I get the following..
1895793 SWERR log threshold exceeded at CEM, please upload the log // [XCEM] SWERR Log pattern match timed-out at ./clear.pl line 45 Why is it that my script is timing out? Can you help Fish or Kevin? Thanks a lot. Update.. I removed the waitfor line and it worked. But the alarms still didn't clear up.. I think I need to put a sleep(3); on each command. Will keep you posted.
(This post was edited by cuboidgraphix on Jan 21, 2009, 2:30 PM)
|
|
|
Edit Log:
|
|
Post edited by cuboidgraphix
(User) on Jan 21, 2009, 2:25 PM
|
|
Post edited by cuboidgraphix
(User) on Jan 21, 2009, 2:30 PM
|
|
|  |