wpi-monitor: simple script to keep the wireless link up

I’m using a rum device in Host AP mode, so every time I try to send a large file or open many connections, the wireless link breaks down (gets “no carrier” instead of “associated”). To get it back up, I have to pull the interface on the station computer (wpi) down and then back up.

To automate the process, I’ve written this simple script. To be run with root/operator permissions.

# Stop wpi from falling off.

if=wpi0 # interface name

while true
        # see if it has "no carrier" status, by looking for "no"
        status=`ifconfig $if | grep status | cut -d ":" -f 2 | cut -d " " -f 2`

        # bourne shell string comparison... you can has it
        if [ "$status" = "no" ] ; then
                ifconfig $if down
                ifconfig $if up
#               echo down
#               echo up

        sleep 1

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: