#!/usr/bin/perl # get_link # # Extracts linkpairs from wleiden.conf files # $scriptname="get_link.pl"; $author ="Ous"; $versionstring="0.2"; $versiondate="06Jun07"; # # # License: WL # # History: # ver: date: Desc: # 0.1 5jun07 Initial attempt # 0.2 6jun07 Clean up output, create reduced linklist, ... # # Todo: # fix multiple links on same adapter # # Known issues: # ======================================================================================== $nodelist="./nodelijst.txt"; $outfile="./link_list.txt"; $outfile2="./linkreverse_list.txt"; $outfile3="./reduced_linklist.txt"; #=======MAIN============ &init; $config_end=false; while($node=) { chomp($node); if ($node !~ /^#/) {$infile="$node/wleiden.conf";} &process_configfile; } &verwerk; &close_all; #======================= #======================== sub init { $date=localtime; #print "$date\n"; ($dat_weekday, $dat_month, $dat_day, $dat_time, $dat_year)= split(/\s+/,$date); $lastchange="$dat_day $dat_month $dat_year"; open (NODELIST,$nodelist) or die "Can't open $nodelist"; open (OUTFILE, ">$outfile"); open (OUTFILE2, ">$outfile2"); open (OUTFILE3, ">$outfile3"); $linkcount=0; } #======================== #======================== sub close_all { close (NODELIST); close(OUTFILE); close(OUTFILE2); close(OUTFILE3); } #======================= #======================== sub process_configfile { open(CONF, $infile); while ($line=) { chomp($line); $line =~ s/ //g; if ($line =~ /^\#/) { $key="";$value=""} else { ($key, $value)=split(/\=/,$line); if ($key =~ /\$nodename/) { $nodename=$value; $nodename=~ s/[\';\s]//g;$nodename=~ tr/[A-Z]/[a-z]/ } if ($key =~ /\$config.+\}/) { $id=$key; $id =~ s/.*?\'//; $id =~ s/\'.*//; $ID=$id; $value=~ s/.+\<\ $b} keys (%fromtohash)) {if ($fromtohash{$k} !~ /test/ ){print OUTFILE3 "$k\t$fromtohash{$k}\n"}} }