On Mar 12, at 12:57 PM, Dan Langille wrote:
> 
> My mom uses FreeBSD.  More precisely, she uses Pine to send/receive 
> email.  At present, she has a DSL connection.  She's soon to change 
> to a dial up account.
> 
> What I'm planning to do is provide her with a shell script which will 
> send/receive email for her.  She'll run it to check for mail and when 
> she's done composing her outgoing mail.
> 
> My initial untested idea is: 
> 
> - ppp --dial HerISP,
> - wait for the connection to come up

I can get you this far.

> - kill the connection

This one, too. See the attached script.

Note that I had to hack some files in /etc/ppp to get things to work right
(auto-dialup when anything WAN-related happens). If you want these too,
I can supply them, but I have to wonder if the list is the right forum?

I used kernel-mode PPP, BTW.

> Cheers
> -- 
> Dan Langille : http://www.langille.org/

Dave

-- 

Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"
#!/bin/sh
#
# EZ interface to pppctl. Supports connecting, disconnecting, setting the
# timeout value, showing the bundle, and testing the line (the last returns
# 0 if line up, the others return undefined).

# for cron
PATH=$PATH:/usr/sbin
# defined in /etc/ppp/ppp.conf
COMMCHNL=/var/run/ppp

TIMEOUT=180
NOISY=-v

test_up ()
{
        pppctl -v $COMMCHNL quit 2>/dev/null |grep ^PPP >/dev/null
        return $?
}

syntax ()
{
        echo "usage: "${0##*/}" -c|-d|-s|-v [-t timeout] [-q]"
        echo "       -c, -d, and -t always set a timeout (default="$TIMEOUT")"
        exit
}

if [ $# -eq 0 ]; then
        syntax
fi

while getopts "cdqst:v" OPT; do
        case $OPT in
                c) FLAG=c;;
                d) FLAG=d;;
                q) NOISY=;;
                s) FLAG=s;;
                t) TIME=$OPTARG;;
                v) FLAG=v;;
                *) syntax;;
        esac
done

if [ "$TIME" -o "$FLAG" -a "$FLAG" != "v" -a "$FLAG" != "s" ]; then
        if [ "$TIME" ]; then
                TIMEOUT=$TIME
        fi
        pppctl $NOISY $COMMCHNL set timeout $TIMEOUT
fi

case $FLAG in
        c) test_up;
           if [ $? -eq 0 ]; then
                if [ "$NOISY" ]; then
                        echo "Line is up"
                fi
                exit
           fi;
           exec pppctl $NOISY $COMMCHNL dial;;
        d) exec pppctl $NOISY $COMMCHNL close;;
        s) exec pppctl $NOISY $COMMCHNL show bundle;;
        v) test_up;
           RETVAL=$?;
           if [ "$NOISY" ]; then
                if [ $RETVAL -eq 0 ]; then
                        echo "Line is up"
                else
                        echo "Line is down"
                fi
           fi;
           exit $RETVAL;;
esac

Reply via email to