Hi All,

   time for me to ask dumb questions again...

    I have a script, what i want it to do is scan through a Cisco
router Config file (nicely saved in a text file already so no need for
and SNMP), then output it to a .csv file.
I an using the  Cisco::Reconfig; module to help me out.

  My problem is when i try to remove a charidge return from a
variable, the value ends up blank, you will see from below i have
tryed a few different ways to make this work, but i am lost (i suspect
some basic Perl knowledge is missing).
  any help would be most appreciated thank you .

cut down version of
Script-------------------------------------------------------------------------------------------
#!/usr/local/bin/perl
use strict;
use Cisco::Reconfig;
use warnings;

############################################################
# Scan  routers configs
# Parameters :
#               router name of site to be found
#               $router.cfg file : this is the data file
# Returns :
#               outputs a csv with port info from config
############################################################
my($routerName)=$ARGV[0] || die  "you must supply a router name on the
command line";
my($findVars)="discription, ip address, cctReff, siteName, vpnName";
my($findInterfaces)="Serial,POS,ATM";
my($interface);

if ( ! -r "dir/$routerName.cfg") {die "could not read
currIPS/$routerName.cfg : $!";}

my $config = readconfig("dir/$routerName.cfg");

for my $interfaceTypes (split/\,/,$findInterfaces) { #loop throught
interface types
  
  for my $found ($config->get('interface')->all($interfaceTypes)) { #
loop through found interfaces

    $interface=getPortFromFullInterface("$found") || die "$!";
#    chomp $interface;  <-- i trtyed this 
    
    print "$interface\n";
  }
} #end for

sub getPortFromFullInterface {
#  chomp @_;     <-- i trtyed this 
  my $part="@_";

  $part =~ s/^interface //g;
  $part =~ s/ point-to-point//g;
  $part =~ s/ multipoint//g;
#  $part =~ s/\n$//g;            <-- i trtyed this 
  return($part);
};



/Script-------------------------------------------------------------------------------------------

SampleData-------------------------------------------------------------------------------------------

!
interface ATM0
 description ~atm0 ~ab_cdefg-r10-001 ~1/123 ~IS5B0000000 ~CBUK00000000
~00000000000
 bandwidth 288
 no ip address
 no atm ilmi-keepalive
 dsl operating-mode auto
no shutdown
!
interface ATM0.38 point-to-point
 description vpn ~cscngte_vpn1
 ip address 123.123.123.123 255.255.255.255
 pvc 0/38 
  oam-pvc manage
  oam retry 3 5 1
no shutdown
 !
\SampleData-------------------------------------------------------------------------------------------
-- 
--
Fnord...
<-- http://23.me.uk --> <-- http://info-x.co.uk  --> <--
http://wiki.seti23.org --> <-- Get FireFox Now -->

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to