NAME
PDK::Device::Cisco - Interacts with Cisco devices, managing connections, commands, and configuration backups.
SYNOPSIS
use PDK::Device::Cisco;
my $device = PDK::Device::Cisco->new(
host => '192.168.1.1',
username => 'admin',
password => 'password'
);
$device->login();
$device->send('show running-config');
$device->getConfig();
$device->ftpConfig();
DESCRIPTION
This module provides methods to interact with Cisco devices, including login, command execution, and configuration backups over FTP.
ATTRIBUTES
- prompt
-
Regex for the normal mode prompt (default: '\S+[#>]\s*\z').
- enPrompt
-
Regex for non-privileged mode prompt (default: '\S+[>]\s*\z').
- enCommand
-
Command to switch to enable mode (default: 'enable').
METHODS
- errCodes
-
Returns an array of regexes for common error patterns (e.g., "Permission denied", "Invalid command").
- waitfor($prompt, $params)
-
Waits for the specified prompt and handles device responses interactively.
Parameters: $prompt - The prompt to match (optional) $params - A hash reference containing send command and other options (optional) send - The command to send continue - Whether to continue execution (default: false) cache - Whether to cache the output (default: true)
Returns: The output of the command execution
- runCommands($commands)
-
Executes a list of commands in configuration mode, automatically adding commands like "configure terminal" and "copy running-config startup-config" if needed.
Parameters: $commands - An array reference containing the list of commands
Returns: None
- getConfig
-
Retrieves the device's running configuration, excluding specific lines (e.g., "ntp clock-period").
Returns: A hash reference containing a success flag and the configuration content
- ftpConfig($hostname, $server)
-
Backs up the running configuration to an FTP server.
Parameters: $hostname - Optional hostname $server - FTP server address (if not provided, uses the PDK_FTP_SERVER environment variable)
Returns: The result of the command execution
AUTHOR
WENWU YAN <968828@gmail.com>
LICENSE AND COPYRIGHT
Copyright (C) 2024 WENWU YAN
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.