1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#!/usr/bin/perl -w
use Net::Telnet ();
sub QuitterApplication
{
exit(0);
}
my ($hostname, $port, $telnet);
$hostname="172.16.40.3";
$port="23";
$timeout_time=3;
my ($forecast, $t);
$telnet = new Net::Telnet ( Timeout=>$timeout_time, Errmode=>'die');
$telnet->open(Host => $hostname, Port => $port);
my $prematch=();
my $match=();
my $x=0;
my $reponse=();
($prematch,$match)=$telnet->waitfor("/>|#|%|:/");
print "$prematch$match";
$prematch=();
while ($x != 1){
$reponse=<STDIN>;
chop $reponse;
if ($reponse eq "quit"){exit (0)}
$telnet->print("$reponse");
($prematch,$match)=$telnet->waitfor("/>|#|%|:/");
$prematch=~s/$reponse//;
$reponse=();
print "$prematch$match";
if ($match =~/%/){
($prematch,$match)=$telnet->waitfor("/>|#|%|:/");
print "$prematch$match";
}
} |