View Single Post
stopgap's Avatar
Posts: 139 | Thanked: 135 times | Joined on Jan 2010 @ Cambridgeshire, UK
#29
Originally Posted by Matan View Post
This script should disconnect from network (wlan or GPRS/UMTS) after 5 to 10 minutes of no received packets:

Code:
#!/bin/sh
a=`ifconfig phonet0 | grep RX.p | cut -d: -f2`
c=`ifconfig wlan0 | grep RX.p | cut -d: -f2`
b=$a
d=$c

while true ; do
        sleep 300
        a=`ifconfig phonet0 | grep RX.p | cut -d: -f2`
        c=`ifconfig wlan0 | grep RX.p | cut -d: -f2`
        if [ "$a" == "$b" -a "$c" == "$d" ] ; then
                dbus-send --system --dest=com.nokia.icd /com/nokia/icd_ui com.nokia.icd_ui.disconnect boolean:true
        fi
        b=$a
        d=$c
done
Thanks Matan for writing this script. To my surprise I can even vaguely follow it even though I consider myself a complete n00b when it comes to Linux. It must be all that fiddling with my Linux DD-WRT router installation to get a FON hotspot working that's given me a tentative grounding there!

That said, I have no idea where one would put this to be executed... on the router I have a nice simple web interface (although I've used the busybox telnet access too) for Cron Jobs and startup scripts etc. Could you help me and others out with how to install this script and also exactly which variables to change to alter settings...

As far as I can tell the "sleep 300" gives the 5 minute interval... where does the 10 minute upper range come into things, or is that just assuming two loops of 5 minutes each and data occurring between minute 1-5?

You're grep-ing RX.p - I assume this is received packets. Could you similarly do TX.p for transmitted to add to this script... in fact, is there somewhere you could point me like a wiki on this - I'd be interested to know more about the output from ifconfig and what you can do with it.

Thanks for your help
 

The Following User Says Thank You to stopgap For This Useful Post: