PROXY  WHOIS  RQUOTE  TEXTS  SOFT  FOREX  BBOARD
 Music  Philosophy  Code  Literature  Russian

= ROOT|Technical|Code_Examples|Perl|site_perl|JUNOS|Access|telnet.pm =

page 1 of 4



#
# $Id: telnet.pm,v 1.8 2003/03/02 11:12:10 dsw Exp $
#
# COPYRIGHT AND LICENSE
# Copyright (c) 2001-2003, Juniper Networks, Inc.  
# All rights reserved.  
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 	1.	Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer. 
# 	2.	Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution. 
# 	3.	The name of the copyright owner may not be used to 
# endorse or promote products derived from this software without specific 
# prior written permission. 
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

package JUNOS::Access::telnet;

use vars qw( @ISA $shell_bad_command $state_none $state_shellsh 
    $login_incorrect $prompt_login 
    $prompt_password $prompt_shell $prompt_cli $state_failed $state_login 
    $state_password $state_done $state_cli $state_junoscript 
    $cli_bad_command $unknown_host $command_not_found 
    $command_not_found2 );
use JUNOS::Trace;
use JUNOS::Access;
@ISA = qw(JUNOS::Access);

# First one is FreeBSD second on is Solaris
$unknown_host = "No address associated with hostname|Unknown host";
$command_not_found = "junoscript: .*not found";
$command_not_found2 = "No such file or directory";
$cli_bad_command = "syntax error, expecting <command>";
$cli_unknown_command = "unknown command";
$shell_bad_command = ": .*not found";
$login_incorrect = "Login incorrect";

$state_shellsh = 'sh shell';
$state_xmlmode = 'xml mode';
$state_failed =     'failed';
$state_login = 'login';
$state_password = 'password';
$state_cli = 'cli';
$state_clitest = 'cli test';
$state_junoscript = 'junoscript';
$state_done = 'done';
$state_none = 'none';

$prompt_login = 'login:';
$prompt_password = 'Password:';
$prompt_shell = '[$#]$';
$prompt_cli = '>.*start shell sh';

sub start
{
    my($self) = @_;
    $self->{Leader} = '';

    # state maintenance for login process
    $self->{'login_state'} = $state_login;
    $self->{'login_last_state'} = $state_none;
    
    # properties specific to telnet
    $self->{'password'} = $self->{'password'} || "";

    $self->start_command( "telnet -l " . $self->{login} . " " . 
	    $self->{hostname});
}


### partial diagram of state machine implemented in incoming
#	
#				  [state_login]
#     					|
#     					|
#   |<---(bad command|bad host)---------+
#   |					|
#   |					|
#   |				(wait for 'login:', send login)
#   |				     	|
#   |				     	|
#   |				     	V
#   |				[state_password]
#   |					|
=1=

= PAGE 1 = NEXT > |2|3|4

UP TO ROOT | UP TO DIR

Google
 


E-mail Facebook Google Digg del.icio.us BlinkList Fark Furl Ma.gnolia Netscape NewsVine Reddit Slashdot Spurl StumbleUpon Technorati YahooMyWeb LiveJournal Blogmarks TwitThis Live News2.ru BobrDobr.ru Memori.ru MoeMesto.ru

0.0133281 wallclock secs ( 0.01 usr + 0.00 sys = 0.01 CPU)