#!/usr/bin/perl
#
# Suche nach a-out-Programmen im PATH

$old_dir=`pwd`;
($name=$0) =~ s#.*/##;	# get basename from $0

open(LOGFILE,">/tmp/aout.log") || die ("Konnte Datei /tmp/aout.log nicht anlegen!\n");

printf         "\n\n\t\t        $name: Suche alle a-out Programme. \n\n";
printf LOGFILE "\n\n\t\t        $name: Suche alle a-out Programme. \n\n";

# in $PATH ":" durch " " ersetzen, um 'for' nutzen zu können:
#Bin_Path=`echo $PATH | sed 's/:/ /g'`

@Bin_Path=("/sbin","/usr/sbin","/usr/lib/setup","/bin","/usr/bin","/usr/local/bin",
           "/usr/X11R6/bin","/usr/openwin/bin","/usr/TeX/bin","/usr/games");
chdir "/";

foreach $P (@Bin_Path)
{
 printf "\nBearbeite Bin-Dir $P\n\n";
 chdir $P;
 printf LOGFILE `pwd` . "\n";
 open(FILES,"file * | egrep \"Linux|MAGIC\" |");
   while (<FILES>) { printf LOGFILE "$_" };  #if (/(Linux)|(MAGIC)/); }
   printf LOGFILE "\n";
 close(FILES);
}

close(LOGFILE);
chdir $old_dir;