Created
March 8, 2011 01:46
-
-
Save Packetslave/859690 to your computer and use it in GitHub Desktop.
Generate IOS interface descriptions from an (exported) excel file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
# | |
# Generate interface configs from an exported Excel file | |
# | |
# - assumes the file is exported as tab-delimited | |
# - assumes the first column is the interface name | |
# - joins all other fields into the description | |
# | |
# $ cat interfaces.txt | |
# | |
# e101/1/1 vlan1 server1-02 1.1.1.1/24 eth1 | |
# e101/1/2 vlan2 server2-02 1.1.1.2/24 eth2 | |
# e101/1/3 vlan3 server3-02 1.1.1.3/24 eth3 | |
# | |
# $ perl description.pl interfaces.txt | |
# interface e101/1/1 | |
# description vlan1 // server1-02 // 1.1.1.1/24 // eth1 | |
# interface e101/1/2 | |
# description vlan2 // server2-02 // 1.1.1.2/24 // eth2 | |
# interface e101/1/3 | |
# description vlan3 // server3-02 // 1.1.1.3/24 // eth3 | |
use strict; | |
use warnings; | |
while( <> ) { | |
chomp; | |
my( @fields ) = split /\t/; | |
print "interface $fields[0]\n"; | |
print " description ", join( " // ", @fields[1..$#fields] ), "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment