App-Tel
view release on metacpan or search on metacpan
use App::Tel;
use Getopt::Long qw (:config pass_through);
use Getopt::Std;
use Pod::Usage;
use v5.10;
__PACKAGE__->main() unless caller;
=head1 NAME
tel - script for router logins
=head1 SYNOPSIS
tel gw1-my-device gw2-my-device ...
Options:
-h help message
-l logging
-d debug mode
-v version
-p connection port
-P override profile
-m connection method
-x run script file
-c run commands
-a auto commands
-t sets the timeout
-s sleep between commands
-4 force IPv4 connection
-6 force IPv6 connection
=head1 OPTIONS
=over 4
=item -c
Runs a series of commands that are separated by semicolons.
Example: tel -c "show ver; sh run" gw1-my-device
=item -l
Enables logging to a file /tmp/gw1-my-device.log.
Example: tel -l gw1-my-device
=item -d
Enables debugging, which will warn you if some of the runtime modules fail to
load.
Example: tel -d gw1-my-device
=item -x or --xscript
Runs a command-file file, which is a list of commands for the device. Can be
specified multiple times to run multiple scripts.
If you need to use a newline in the script to get through a prompt then you
can use \r. An example of this might be "reload\ry"
Example: tel -x changes.txt gw1-my-device
=item -a
Specify auto commands to run. This overrides any commands loaded from profiles
and is used for all devices during the session.
Example: tel -a "sh run int vlan35; conf t" gw1-my-device
=item -p
Specify connection port. This overrides any specific port in loaded profiles
and is used for all devices during the session.
Example: tel -p 22 gw1-my-devices
=item -P or --profile
Override the loaded profiles with another defined in telrc. This is useful if
you're logging into the IP of a server rather than using the DNS name.
Example: tel -P zhone 10.9.9.9
=item -A
This overrides the profile after you've logged into the server. You might
need this if you're logging into an out of band server made by one vendor to
access the console of a device made by another vendor.
Example: tel -A zhone oob-test-lab:2004
=item -m
Specify connection method. This overrides specific methods in loaded profiles
and is used for all devices during the session.
Example: tel -m ssh gw1-my-devices
=item -t
Specify timeout in seconds. The default is 90 seconds. This overrides
specific methods in loaded profiles and is used for all devices during the
session.
Example: tel -t 30 gw1-my-devices
=item -s
Specify timeout in seconds to sleep between commands. This only applies to
commands specified for -x, -c or -a. This will use Time::HiRes if it's
installed for sub-second sleep values like 0.5.
Example: tel -s 3 -x myfile.txt gw1-my-devices
=item -S
Specify timeout in seconds to sleep between commands. This applies to
interactive sessions as well as login commands. This will use Time::HiRes
( run in 0.748 second using v1.01-cache-2.11-cpan-6aa56a78535 )