Sent: Sunday, June 22, 2014 at 4:08 PM From: "Pierre Labastie" <[email protected]> To: "BLFS Support List" <[email protected]> Subject: Re: [blfs-support] Help needed with simple script Le 22/06/2014 16:33, Cliff McDiarmid a écrit : > Hi > > Can someone point me in the right direction here please? > > I'm trying to write a simple script to remove one wireless module(if it is > present)and install another. If the module is not present then I need the > existing module(iwlwifi) deleted. > > I can't get this to work however: > > #! /bin/bash > > if [ -e $r8712u ]; then > rmmod r8712u; > insmod /lib/modules/3.13.3/kernel/drivers/net/wireless/iwlwifi/iwlwifi.ko; > insmod /lib/modules/3.13.3/kernel/drivers/net/wireless/iwlwifi/dvm/iwldvm.ko; > echo "Module r8712u is removed and iwlwifi installed." > else > rmmod iwldvm; > rmmod iwlwifi; > echo "Module iwlwifi is removed." > fi Thanks Pierre
>First, semicolons at the end of a line are not needed. They are only needed as >a separator between commands on the same line. OTOH, they do not hurt in this >case; I think. OK thanks >I think there are several points which may be causing trouble: >.First, "if [ -e $r8712u ]" tests whether a file exist, not whether a module is >loaded. >Second, $r8712u is a variable. It should contain the name of the file whose >presence is to be tested. try: >echo $r8712u >and you'll see what is in there Tried, this makes no difference >Third, "rmmod/insmod" do not delete/install modules. They unload/load the >modules from/into the kernel. r8712u Sorry my mistake, I am trying to load and unload. What I'm trying to do is to speed up the unloading of the iwlwifi module(and loading later)prior to plugging in an external wifi receiver using the r8712u module(they can't coexist, or won't). At the moment the error is: rmmod: ERROR: Module r8712u is not currently loaded insmod: ERROR: could not insert module /lib/modules/3.13.3/kernel/drivers/net/wireless/iwlwifi/iwlwifi.ko: File exists insmod: ERROR: could not insert module /lib/modules/3.13.3/kernel/drivers/net/wireless/iwlwifi/dvm/iwldvm.ko: File exists Module r8712u is removed and iwlwifi installed If I split the script into two separate e.g. [ -e $r8712u ]; then rmmod r8712u; insmod /lib/modules/3.13.3/kernel/drivers/net/wireless/iwlwifi/iwlwifi.ko; insmod /lib/modules/3.13.3/kernel/drivers/net/wireless/iwlwifi/dvm/iwldvm.ko; echo "Module r8712u is removed and iwlwifi installed." fi and run them they work. But I'd like them to work as a single script. Cliff -- http://lists.linuxfromscratch.org/listinfo/blfs-support FAQ: http://www.linuxfromscratch.org/blfs/faq.html Unsubscribe: See the above information page
