:File or directory not found [closed]

I am working on a BASHScript to start wlan monitor mode without interefering with NetworkManager and I am having trouble with this function:

serial_setup(){

local file_name=$1
while IFS =, read PhysicalDevice ItfAlias ItfMode;
do
iw $PhysicalDevice interface add $ItfAlias type $ItfMode
ifconfig $ItfAlias up
done < file_name

}

The above function reads a textfile in format:

PhysicalDevice1,alias1,mode1
PhysicalDevice2,alias2,mode2
PhysicalDevice3,alias3,mode3

I need to find out the cause of error and optimum solution?

EDIT: Here is the full code: MM Script I have to use paste`bin due to trouble pasting and formatting the code here

Answer

It looks to me as if you have forgotten a $ on a variable. You have also forgotten to double-quote several other variables:

serial_setup () {
    local file_name="$1"

    while IFS=, read PhysicalDevice ItfAlias ItfMode; do
        iw "$PhysicalDevice" interface add "$ItfAlias" type "$ItfMode"
        ifconfig "$ItfAlias" up
    done <"$file_name"
}

See “Security implications of forgetting to quote a variable in bash/POSIX shells“.

Leave a Reply

Your email address will not be published. Required fields are marked *