NAME

App::Tel - A script for logging into devices

VERSION

0.2008

SYNOPSIS

tel gw1-my-dev

See the README and COMMANDS files for examples of usage and ways to extend the application.

AUTHOR

Robert Drake, <rdrake at cpan.org>

COPYRIGHT & LICENSE

Copyright 2006 Robert Drake, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

METHODS

new

my $tel = App::Tel->new();

Creates a new App::Tel object.

disconnect

$self->disconnect($hard_close);

Tears down the session gracefully and resets internal variables to their default values. Useful if you want to connect to another host after the first one.

If you supply a true value, it will hard_close the session.

load_syntax

$self->load_syntax('Cisco');

This attempts to load syntax highlighting modules. In the above example, Cisco would append Colors to the end and get CiscoColors.pm. If it can't find the module it just won't load it.

Multiple files can be chain loaded by using plus:

$self->load_syntax('Default+Cisco');

load_config

Loads the config from /etc/telrc, /usr/local/etc/telrc, $ENV{HOME}/.telrc2, or it can be appended to by using the environment variable TELRC, or overridden by calling load_config with an argument:

$self->load_config('/home/user/.my_custom_override');

hostname

$hostname = $self->hostname("hostname");

Called to parse the hostname provided by the user when first making a connection. If the hostname has special attributes like a port designation, it's parsed here.

This also looks up the profile for the hostname to see if it needs to be translated because of an alias. The final hostname is stored and returned.

methods

$self->methods();

This is used to determine the method used to connect to the remote device. Generally, the CLI argument -m has the highest priority. The uri should be second, profiles third, and the defaults would be last. If called without arguments it will return whatever the currently decided method array is. If called with an argument that will be set as the new method array.

If you call it multiple times it won't change right now. I may need to rethink this later but right now it works with the way the program flows. $self->disconnect removes all methods so connecting to another router will run this again.

$self->methods('ssh', 'telnet');

profile

$profile = $self->profile;
$profile = $self->profile('profilename', $replace);

Called without arguments this will return the current profile. If called with a profilename it will load that new profile on top of whatever profile currently exists. You can set the second argument to true if you want to replace the current profile with the new one.

logging

$self->logging('filename');

Turns on logging for this session. If you specify a filename it will log to /tmp/<filename>.log, otherwise it will use /tmp/<hostname>.log.

control_loop

$self->control_loop('commands', 'another command');

This is where control should be passed once the session is logged in. This handles CLI commands passed via the -c option, or scripts executed with the -x option. It also will handle parameters passed to it by the calling method as autocmds that execute before dropping into an interactive session.

Calling this without any commands will just run interact()

TODO: We should probably move the command running into two methods that process_commands and run_commands to make them easier to test and reuse for other things.