Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ### This script is designed to telnet into a Cisco router, issue a set of commands intended to "break" the configuration
- ### and then disconnect from the telnet session.
- ############################################################################
- ############################################################################
- use Net::Telnet ();
- $username = "yourUSER";
- $password = "yourPASS";
- @issue_commands = (
- 'enable',
- 'configure terminal',
- 'interface eth 0/1',
- 'shutdown',
- 'exit',
- );
- #make the telnet connection
- $t = new Net::Telnet (Timeout => 10,Prompt => '/[\$%#>] $/');
- $t->open("$server");
- $t->login($username, $password);
- #loop through this function for every entry in the @issue_commands array
- foreach $command (@issue_commands){
- #issue the command and store it in the array @telnet_output
- @telnet_output = $t->cmd($command);
- #dump contents of @telnet_output array to the screen
- foreach(@telnet_output){
- chomp;
- print "$_\n";
- }
- }
Add Comment
Please, Sign In to add comment