![]() |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
You create a file (say /usr/local/bin/scriptname) with this content, make sure it is executable (with a command like)
chmod a+x /usr/local/bin/scriptname First, you should run it to see if it does what you want. If you are sure you want it to start at boot time, the easiest way is probably to create a file /etc/event.d/autodisconnect, containing: Code:
description "Run a script to disconnect idle networks" It can be up to 10 minutes, if last transfer happens a few seconds after the sleep starts, because the next check will see this transfer. I believe using received makes more sense, since sometime the network appears up, but the other side is not there. In that case applications might continually send data, but nothing will be received. I don't know of a wiki explaining all this, but you seem to be on the right track for understanding. I can think of no better way to do it than looking at simple scripts, and playing with them. If you don't have a Linux desktop, search for "manual page" of each command you need to learn. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Ok, so I've gotten quite far acutally. I have tailored the script a little and after testing that it worked, have now got it installed as a startup, as per your instructions above.
Should I wish to terminate this script - what would I need to do? I have HTOP installed and was poking around with that. I'm also aware of kill and ps now, but don't know what it is I'm supposed to be killing. Should the process be listed in there with a PID? Thanks again for your help here, you've really opened up the gateway here re: linux scripting. I never knew where to start and this has been a brilliant introduction. Cheers :D ** EDIT Ok, so it didn't run. Did I need to CHMOD the file which ran the script file in the same way too? That's the only thing that I didn't do... |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Let us know if your battery life has improved with everyday usage after using the script.
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Do you mean that the script runs when you run it manually, but does not start automatically? I am not sure about the operation of the upstart system. Perhaps you need to add an ampersand after the call to the script, so the line should be:
/usr/local/bin/scriptname & Also /usr/local/bin/scriptname needs to be executable, not the file in /etc/event.d |
Re: Allow widgets/apps to automatically connect and then automatically disconnect internet connection. Possible?
Quote:
|
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Yes... the script runs fine manually. I can't get upstart to start it - it just doesn't work. Is there some way I could get my script to set a variable or something to show it is running? I tried using export to set a global variable but it seems to be limited to the shell in which the script is running... unless I misunderstanding (this is only my second day writing shell scripts so it could well be that! ;)
How would I go about piping the time to a text file for example, or is there a way to set a variable that I could check this way? Thanks again for your help :D |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Use something like
date >> /tmp/a.log |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
This is an interesting idea, I hate to forgetting turning wifi off before going to bed and find my phone dead in the morning.
Installed script and it works fairly good for 3G. Seems like wlan keeps sending packets although the device is idle. A more accurate way to turn connections off would be to check for user inactivity but I have no idea how to check that via a shell script. |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
As it stands I have an executable script which disconnects properly and logs startup and disconnections to a text file. It executes manually without error but I just cannot autostart it. Also, does anyone know if there's a way to send a notification message from a script? I'm talking about the notifications which confirm an SMS delivery or a website's security or "code accepted" when you unlock - the pop up ones which fade & slide away automatically. Thanks again for all the help! |
Re: Connect to Internet on demand & disconnect automatically, particularly for GPRS?
Quote:
Code:
run-standalone.sh dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"Message goes here" |
All times are GMT. The time now is 22:15. |
vBulletin® Version 3.8.8