LJ Archive

Listing 3. Loading Audio Card Module with Perl

opendir MODDIR, "/lib/modules/2.4.20/kernel/drivers/sound/";
while($mod = readdir MODDIR){
  next if $mod =~ /^\.{1,2}$/;
  $mod =~ s/\.o$//;
  system "modprobe $mod > /dev/null 2>&1";
  last if -e "/dev/sound/dsp";
  system "rmmod $mod > /dev/null 2>&1";
}
closedir MODDIR;
LJ Archive