$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;
print"Finished\n";
#
#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 <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.
die"Zu wenige Parameter!\nconvert.pl <Eingabedatei> <Ausgabedatei>"if$i<2;
print"\n";
print"Eingabedatei $ARGV[0]\n";
print"Ausgabedatei $ARGV[1]\n";
openIN,"<$ARGV[0]";
openOUT,">$ARGV[1]";
@INF=<IN>;
foreach(@INF){
chomp;
router()if($_=~ /^!!ROUTER/);
router()if($_=~ /^!!SWITCH/);
router()if($_=~ /^!!FIREWALL/);
}
closeIN;
closeOUT;
subrouter{
$read_v=0;
# Variablen lesen
foreach(@INF){
$read_v=1if($_=~ /^!!VARIABLEN/);
lastif($_=~ /^!!CONFIG/);
nextif($_=~ /^!/);
read_var($_)if($read_v);
}
# Konfig lesen
$read_c=0;
foreach(@INF){
chomp;
$read_c=1if($_=~ /^!!CONFIG/);
if($read_c){
if($_=~ /<.*>/){
($vn)=$_=~/(<.*>)/;
$_=~s/$vn/$VARS{$vn}/;
nextif($VARS{$vn}eq"");
}
# und schreiben
printfOUT"$_\n";
}
}
# hostname-confg erstellen
($pfad,$file)=$ARGV[1]=~/(.*)\/([^\/]*)$/;
$hostname=$pfad.'/'.$VARS{'<HOSTNAME>'}.'-confg';
print"Ausgabedatei 2 $hostname\n";
openHN,">$hostname";
printfHN"\n!\nend\n\n";
closeHN;
}
subswitch{
}
subfirewall{
}
subread_var{
$l=$_[0];
if($l=~ /<.*>.*=.*/){
($vn,$vv)=$l=~/(<.*>).*=[\s]*(.*)/;
$VARS{$vn}=$vv;
}
}
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.