#!/usr/bin/perl # # Remove a module from the kernel $INSMOD="/sbin/insmod"; $RMMOD="/sbin/rmmod"; $USE="USE:\n\trtunload [options] file \n\n". "options:\n". "\t-i\t\tInsert file\n" . "\t-r\t\tRemove file\n"; $OPTION_INSERT=0; $OPTION_REMOVE=0; $REM_MODULES=""; if ($#ARGV < 0) { die $USE; } foreach $arg (@ARGV) { if ($arg eq "-i") { $OPTION_INSERT = 1; next; } if ($arg eq "-r") { $OPTION_REMOVE = 1; next; } if ($OPTION_REMOVE || ($OPTION_INSERT == 0 && $OPTION_REMOVE == 0)) { system ("$RMMOD $arg") == 0 or die "Error removing modules"; } if ($OPTION_REMOVE) { $REM_MODULES = $arg." ".$REM_MODULES; } } if ($OPTION_REMOVE && $OPTION_INSERT) { die "Only one option can be used\n"; } if ($OPTION_REMOVE) { system("$RMMOD $REM_MODULES") == 0 or die "Error removing modules"; }