Hi again, ok i made the changes sugested, but something is still wrong. the output im getting is ---------------------------------------------------------------------------------- "interface is "ATM0 "interface is "ATM0.38 ----------------------------------------------------------------------------------
ie the " is at the start of the line??? i think this is some thing to do with the way Cisco::Reconfig is returning the values, becouse this happens every time i chomp a value i get from it. any one why this might be happening? yours most confused, Ritchie new code----------------------------------------------------------------------------------- #!/usr/local/bin/perl use strict; use Cisco::Reconfig; use warnings; ############################################################ # Scan PE routers configs from the rcl box # 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"; if ( ! -r "currIPS/$routerName.cfg") {die "could not read currIPS/$routerName.cfg : $!";} my $config = readconfig("currIPS/$routerName.cfg"); for my $interfaceTypes (split/\,/,$findInterfaces) { #loop throught interface types for my $found ($config->get('interface')->all($interfaceTypes)) { # loop through found interfaces my $interface=getPortFromFullInterface($found); print "\$interface is \"$interface\"\n"; } } #end for sub getPortFromFullInterface { my $part=shift; chomp($part); $part =~ s/^interface //g; $part =~ s/ point-to-point//g; $part =~ s/ multipoint//g; return($part); }; -------------------------------------------------------------------------- On Mon, 17 Jan 2005 19:46:36 +0100, Tor Hildrum <[EMAIL PROTECTED]> wrote: > On Mon, 17 Jan 2005 17:57:28 +0000, RichT <[EMAIL PROTECTED]> wrote: > > 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 . > > chomp($var); is perfectly valid. > > Try this code: > > > sub getPortFromFullInterface { > > my $part = shift; > > print "I'm inside getPortFromFullInterface(), \$part is: $part\n"; > > > $part =~ s/^interface //g; > > $part =~ s/ point-to-point//g; > > $part =~ s/ multipoint//g; > chomp($part); > > > return($part); > > }; > > Tor > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > <http://learn.perl.org/> <http://learn.perl.org/first-response> > > -- -- Fnord... <-- http://23.me.uk --> <-- http://info-x.co.uk --> <-- http://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>