;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   Example IPDial 2.1 login script for AmiTCP with PPP
;   $VER: Login-PPP.IPDial 2.1 (16.04.96)
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   You have to call IPDial with the SANADEV option because there is
;   no DEVICE command in here. This script uses the variable $LoginID, so
;   it doesn't have to be changed for different users. The terminal mode
:   is used for entering the corresponding password.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   Send initialization command

    SEND "\r\n"
    DELAY 1
    SEND "ATZ\r"


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   Wait for the modems ok; break, if timeout (default: 5 seconds)

    WAIT "OK"
    ON STATUS GOTO TIMEOUT


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   Initialize the modem not to hang up, when IPDial terminates (this
;   will make DTR becoming low)

    SEND "AT&D0\r"
    WAIT "OK"
    ON STATUS GOTO TIMEOUT


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   Dialing (2 lines)...

Dial:
    ECHO "Trying line 1...\n"
    SEND "ATDT XXXXXXXXXX\r"
    WAIT TIMEOUT=60 "CONNECT" "BUSY" "NO CARRIER"
    ON STATUS GOTO TIMEOUT Login

    ECHO "Line 1 is busy - trying second one..."
    DELAY 30
    SEND "ATDT XXXXXXXXXX\r"
    WAIT TIMEOUT=60 "CONNECT" "BUSY" "NO CARRIER"
    ON STATUS GOTO TIMEOUT Login

    ECHO "Both lines are busy - delaying 20 seconds..."
    DELAY 20
    GOTO Dial


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   Okay, we are connected. Login into the host.

Login:
    ECHO "Connection established!\n"

    WAIT "mode:"
    ON STATUS GOTO TIMEOUT
    SEND "ppp\r"

    WAIT "login:"
    ON STATUS GOTO TIMEOUT
    SEND $LoginID\r

    WAIT "password:"
    ON STATUS GOTO TIMEOUT
    ECHO "\nPlease enter password for" $LoginID ": "
    TERMINAL EOF="\r" NOECHO

    ECHO "\nWaitiung for PPP...\n"
    WAIT "starting PPP"
    ON STATUS GOTO TIMEOUT
    EXIT 0


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;   Error message: Timeout

TIMEOUT:
    ECHO "\nTimeout. Entering terminal mode.\n"
    TERMINAL NOECHO RAW
    EXIT 0

