tags:

views:

115

answers:

1

How can i figure out if I have wifi devices connected to my PC thru bash scripting? * Is there anyway aside from 'iwconfig'? * If i have two devices connected and am using device A. Now if device A is down, then how can i setup to use device B instead?

I'm just learning bash scripting, tutorials kinda confused me with all the new "codes" and syntax, though I already read some. Just give a few ideas to start with pls.. =)

A: 
depend() {
        before fuse
}

start() {
        ebegin "Starting Networking"
        /etc/init.d/net.eth0 start

       if [ `ping -c 1 192.168.1.1 | grep "Destination Host Unreachable"` ]; then
                /etc/init.d/net.eth0 stop

                if [ -e /sys/class/net/wlan0 ]; then
                        /etc/init.d/net.wlan0 start
                fi
        fi
        eend
}

Change according to ur Wlan card name .

this information taken from http://www.linuxquestions.org/questions/linux-general-1/detect-if-a-network-device-is-connected-in-a-bash-script-692824/

joe
As far as I am aware, only Gentoo uses `openrc` for network setup. Debian uses `ifupdown` and Fedora uses `sysconfig`; this solution will work on neither.
ephemient