#!/bin/perl use strict; use warnings; use Net::SNMP; my $i=@ARGV; die "\nZu wenige Parameter!\n\nStartTftpDownload.pl \n Source 1: networkFile 3: startupConfig 4: runningConfig Destination 1: networkFile 3: startupConfig 4: runningConfig Example C:\\>StartTftpDownload.pl 172.23.210.151 172.23.210.222 5NMP-Wr1t3-(0mm 1 4 getit.conf " if $i<6; print "\n"; my $ROUT = $ARGV[0]; my $TFTP = $ARGV[1]; my $COMM = $ARGV[2]; my $SOUR = $ARGV[3]; my $DEST = $ARGV[4]; my $FILE = $ARGV[5]; my ($session, $error) = Net::SNMP->session( -hostname => $ROUT, -version => 'snmpv2', -community => $COMM, ); if (!defined $session) { printf "ERROR: %s.\n", $error; exit 1; } my $SES=".111"; my $OID="1.3.6.1.4.1.9.9.96.1.1.1.1.2" . $SES; $session->set_request(-varbindlist => [ $OID, INTEGER, '1' ], ); #The ConfigCopyProtocol is set to TFTP $OID="1.3.6.1.4.1.9.9.96.1.1.1.1.3" . $SES; $session->set_request(-varbindlist => [ $OID, INTEGER, $SOUR ], ); #Set the SourceFileType to networkfile #running-config $OID="1.3.6.1.4.1.9.9.96.1.1.1.1.4" . $SES; $session->set_request(-varbindlist => [ $OID, INTEGER, $DEST ], ); #Set the DestinationFileType to running-config #networkfile $OID="1.3.6.1.4.1.9.9.96.1.1.1.1.5" . $SES; $session->set_request(-varbindlist => [ $OID, IPADDRESS, $TFTP ], ); #Sets the ServerAddress to the IP address of the TFTP server $OID="1.3.6.1.4.1.9.9.96.1.1.1.1.6" . $SES; $session->set_request(-varbindlist => [ $OID, OCTET_STRING, $FILE ], ); #Sets the CopyFilename to your desired file name. $OID="1.3.6.1.4.1.9.9.96.1.1.1.1.14" . $SES; $session->set_request(-varbindlist => [ $OID, INTEGER, '1' ], ); #Sets the CopyStatus to active which starts the copy process. $OID="1.3.6.1.4.1.9.9.96.1.1.1.1.14" . $SES; $session->set_request(-varbindlist => [ $OID, INTEGER, '6' ], ); #Sets the CopyStatus to delete which cleans all saved informations out of the MIB exit; # #ccConfigCopyProtocol #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.2 #Type: INTEGER #Options:tftp(1) #ftp(2) #rcp(3) #scp(4) #sftp(5) #Description: Defines whicn protocol is used for the copy process. TFTP is default #ccCopySourceFileType #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.3 #Type: INTEGER #Options: networkFile(1) #iosFile(2) #startupConfig(3) #runningConfig(4) #terminal(5) #Descripton: Defines the source. Either the Source or the DestinatioFileType have to be set to startupConfig or runningConfig. Furthermore the SourceFileType has to be different to the DestinationFileType. #ccCopyDestFileType #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.4 #Type: INTEGER #Options: networkFile(1) #iosFile(2) #startupConfig(3) #runningConfig(4) #terminal(5) #Description: Defines the destination.Either the Source or the DestinatioFileType have to be set to startupConfig or runningConfig. Furthermore the SourceFileType has to be different to the DestinationFileType. #ccCopyServerAddress #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.5 #Type: IP Address #Description: Sets the address of the server to which the file will be copied to. Values like 0.0.0.0 or FF.FF.FF.FF are not allowed for this OID. #ccCopyFileName #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.6 #Type: STRING #Description: Sets the name of the destination or source file. This OID has to be set as far as the destination or sourceFileType are set to networkFile or iosFile. #ccCopyUserName #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.7 #Type: STRING #Description: Sets a username for FTP, RCP, SFTP or SCP. This will overwrite the user name which might have been set over the rcmd remote-username command if RCP is used as protocol. #ccCopyUserPassword #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.8 #Type: STRING #Description: Sets the password for FTP, RCP, SFTP or SCP #ccCopyNotificationOnCompletion #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.9 #Type: INTEGER #Description: Defines if a notification has to be sent after the process has ended. #ccCopyState #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.10 #Type: INTEGER #Options: waiting(1) #running(2) #successful(3) #failed(4) #Description: Shows the copy process’ status. This value will be set after the COPYEntryRowStatus has been set to active. #ccCopyTimeStarted #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.11 #Type: TimeStamp #Description: Shows the last start time of the process or zero if the process never changed the status to running. #ccCopyTimeCompleted #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.12 #Type: TimeStamp #Description: Shows the last time after the process changed from running to successful or failed. #ccCopyFailCause #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.13 #Type: INTEGER #Options: unknown(1) #badFileName(2) #timeout(3) #noMem(4) #noConfig(5) #unsupportedProtocol(6) #someConfigApplyFailed(7) #Description: Shows why the process failed #ccCopyEntryRowStatus #OID: 1.3.6.1.4.1.9.9.96.1.1.1.1.14 #Type: INTEGER #Options: active(1) #notInService(2) #createAndGo(4) #createAndWait(5) #destroy(6) #Description: Shows the process’ status #