Hallo,

I'm trying to write a script that dials up my ISP, establishes a connection
and then sends and fetches mail. The interesting part of the skript looks as
follows:


[...]
if test -f /var/run/pppd.pid then
        /usr/bin/echo                           "pppd running"

        /usr/bin/echo                           "alarming qmail to send mail"
        /usr/bin/killall -ALRM qmail-send

        # once online, the bandwidth should be used :_)
        /usr/bin/echo                   "wwwoffle set to online and fetching"
        /usr/local/bin/wwwoffle -online
        /usr/local/bin/wwwoffle -fetch &

        /usr/bin/echo                           "fetching mail:"
        /usr/bin/fetchmail

        /usr/bin/echo                           "setting wwwoffle to offline"
        /usr/local/bin/wwwoffle -offline &

        ##
        ## somehow check if all mails have been sent
        ##

        /usr/bin/echo                           "closing connection"
        /etc/ppp/ppp-off

        /usr/bin/echo                           "connection closed"
fi


The script will be started from the crontab of root. How can I check if all
mails have been sent? Would a

        while ! /var/qmail/bin/qmail-qstat | grep -q "messages in queue: 0"; do
                sleep 3;
        done

be reliable enough and do the job? I'm not good in script programming ...

Another, more general question: How can I make absolutely sure that the
connection will be closed after some time and the line hung up? I'm afraid
that in the worst case the line might be kept up for one or three days,
tremendously increasing my telephone bill.


GH

Reply via email to