Skip to content

Instantly share code, notes, and snippets.

@Packetslave
Created March 8, 2011 01:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Packetslave/859690 to your computer and use it in GitHub Desktop.
Save Packetslave/859690 to your computer and use it in GitHub Desktop.
Generate IOS interface descriptions from an (exported) excel file
#!/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