NAME
PDK::Device::Cisco - A module for interacting with Cisco devices
SYNOPSIS
use PDK::Device::Cisco;
my $device = PDK::Device::Cisco->new(
host => '192.168.1.1',
username => 'admin',
password => 'Cisco'
);
# Log in to the device
$device->login();
# Execute script in normal mode
$device->execCommands(['show version', 'show ip arp']);
# Execute script in configuration mode, automatically outfitting [config terminal, write]
$device->runCommands(['show version']);
# Retrieve running configuration
my $config = $device->getConfig('hostname');
# FTP configuration backup
my $config = $device->ftpConfig('hostname', 'ftp_server', 'ftp_username', 'ftp_password');
# filename is optional, defaults to device IP address, e.g., 192.168.1.1.cfg
$device->write_file('content', 'filename');
DESCRIPTION
This module provides functionality to interact with Cisco devices, including executing commands, retrieving configurations, and backing up configurations via FTP.
ATTRIBUTES
- prompt
-
The device's default prompt, defaults to '\S+[#>]\s*\z'.
- enPrompt
-
Enable mode prompt, defaults to '\S+[>]\s*\z'.
- enCommand
-
Command to switch to enable mode, defaults to 'enable'.
METHODS
- errCodes
-
Returns a list of possible error codes for checking errors during command execution.
- waitfor
-
Waits for a specific prompt match, automatically executing the script interactively.
- write_file
-
Writes configuration information to a text file.
- runCommands
-
Executes a series of commands and configures the sending mode.
Parameters: - $commands: List of commands (array reference).
- getConfig
-
Retrieves the running configuration of the device.
Returns: A hash reference containing a success flag and configuration content.
- ftpConfig
-
Backs up the running configuration via FTP.
Parameters: - $hostname: Optional hostname. - $server: FTP server address. - $username: FTP username. - $password: FTP password. Returns: The result of executing the command.
AUTHOR
WENWU YAN <968828@gmail.com>