![]() |
How to disconnect modem when postfix queue empty??
in /etc/ppp/ip-up.d/script I have the following that runs fetchmail when the ppp0 interface is up (connected) and when it finish the modem ends internet conection automatically.
Code:
#!/bin/shIn theory i know i could do something using if, else, do, while, until, etc. but in practice i do not know how to develop it. I would like you guys to help me to program and complete this script to work properly. I appreciate the comments. |
use mailq cammand like this..
QU=`mailq |grep 'Total requests'|sed 's/Total requests: //'` if [ "$QU" -ne "0" ] |
When you connect, you run fetchmail and kill, but you want only to kill if the queue is empty .. this will only be checked once .. if the queue at that point is not empty, the connection will stay open indefinitly, not what you want i think. :)
maybe you should fork another script after fetchmail. That script will keep checking the mailqueue and when it's empty, close ppp0 so: Code:
#!/bin/bashCode:
#!/bin/bashI used find, since it's much faster then mailq when you have a lot of mail in the queue. |
Thanks Mark, very usefull your script, i already fix mine with something similar that you post
the script looks now like this and works just as i want Code:
#!/bin/sh |
in your cron entry put: "> /var/log/myscript.log" behind it
|
| All times are GMT +2. The time now is 10:35. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.