#!/usr/bin/perl
open (CURRENT_MACROS, "</local/cipadm/etc/sunray/sunrays");

foreach $line (<CURRENT_MACROS>){
        chop($line);
        if ( $line =~ /^#/ ) { next; }
        if ( $line =~ /^(([A-F0-9]){12})\s+((\d+){1,2})\s+([^ ]*)/){
        #0003BA0CC1F9 11 0.156
        $mac =  $1;
        $room = $5;
        $location{lc($mac)} = $room;	
        }
}



open (GELDKARTE, '/opt/SUNWut/sbin/utuser -Lc | grep Geldkarte|');
foreach $line (<GELDKARTE>){
  if ( $line =~ /Geldkarte\.[a-f0-9]+\s+([A-Za-z0-9]{1}[A-Za-z0-9,\s]+[A-Za-z0-9]{1})\s+([a-f0-9]{12})\s+$/ ) {
	$user{$1} = $location{$2};
  }
}

foreach $luser (sort(keys(%user))) { print "$luser -> $user{$luser}\n"; }
#Geldkarte.0d023102800012251730100410 Max Mustermann               080020fe010b    
