[blfs-support] Help needed with simple script

Pierre Labastie pierre.labastie at neuf.fr
Sun Jun 22 09:27:19 PDT 2014


Le 22/06/2014 17:36, Cliff McDiarmid a écrit :
> 
>  
>  
> 
>>>
>>> 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

>> 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.
That's important: "-e $r8712u" tests whether the content of the variable
$r8712u is an existent file. It does _not_ test whether any module is loaded.
If this variable is empty, it tests whether a file with an empty filename is
present, which I guess is not what is intended. Amazingly enough, the test
returns true in this case! If the variable contains something, it may test a
filename which is completely unrelated to the module name...
That's why I told you to examine the content of this variable, but I was not
clear, sorry. I meant that you type:
echo $r8712u
at the console prompt, and that you see what it outputs.

If I understand what you want to do, I think the test is:
if lsmod | grep -q r8712u ; then ...
but please do not use this command without understanding what it does ("man
bash is your friend". Read about "exit status" and the "if" command)

Pierre


More information about the blfs-support mailing list