expect-send pairs and sub expect-send pairs in chat

expect-send pairs and sub expect-send pairs in chat

Post by Richard Lo » Thu, 09 Jan 1997 04:00:00



My ISP has two possible logins when dialing, depending on waht server you
get, they are:
host:
login:
password:

were hos you enter ppp, slip, shell whatever,
or the server defaults to ppp prompting you for just:

login:
password:

What I belive the solution is:
expect "login:"
[if login is not found expect "host:" send "ppp"]
then send "voltaire"

The problem is that I can not get the sub-expect "host:" and sub-send
"ppp" to work.  I tried (trying to understand the chat manpage):

ogin:--ost: ppp--voltaire

obviously that isn't working, if it sees "ogin:" or "ost:" it sends
"ppp-voltaire"

If anyone can understand this bableing at all please help.

--
Voltaire

http://www.flinet.com/~voltaire

 
 
 

expect-send pairs and sub expect-send pairs in chat

Post by Toni » Fri, 10 Jan 1997 04:00:00



> My ISP has two possible logins when dialing, depending on waht server you
> get, they are:
> host:
> login:
> password:

> were hos you enter ppp, slip, shell whatever,
> or the server defaults to ppp prompting you for just:

> login:
> password:

> What I belive the solution is:
> expect "login:"
> [if login is not found expect "host:" send "ppp"]
> then send "voltaire"

> The problem is that I can not get the sub-expect "host:" and sub-send
> "ppp" to work.  I tried (trying to understand the chat manpage):

> ogin:--ost: ppp--voltaire

> obviously that isn't working, if it sees "ogin:" or "ost:" it sends
> "ppp-voltaire"

> If anyone can understand this bableing at all please help.

Hi,

I can suggest you the use of DIP. Starting with version 3.3.7n-uri,
this program is able of invoking pppd when you use "mode PPP". I
attach here a sample DIP script that is devised for handling the
login sequence you describe. I can't test it, as I don't have access
tou your ISP. You still need the /etc/ppp/options (if you have one),
but remove the lock, 38400 and /dev/cua? options. These will be
handled by DIP now.

Check the DIP man page for a complete description of the program.

For executing the script, do:

dip -v dipscrip.txt

Regards

Toni

[ dipscrip.txt 1K ]
main:
        # this line defines the expected string for modem connection.
        chatkey 14400/LAPM 1
        # port, baud, etc. stuff, change with your data.
        init AT
        port cua2
        speed 38400
        parity N
        databits 8
        stopbits 1
        # do some cleanup on the device.
        flush
        send \r\n\r\n
        # send some initialization strings to the modem, use the ones
        # adecuate for your modem. I use three, remove lines if you don't
        # need all of these.
        sleep 2
        send ATZ\r
        wait OK 10
        if $errlvl != 0 goto init_error
        sleep 2
        send AT&F\r
        wait OK 10
        if $errlvl != 0 goto init_error
        sleep 2
        send ATM1L2\r
        wait OK 10
        if $errlvl != 0 goto init_error
        sleep 2
        # dial your ISP number, use Tnnnnn for tone dialing,
        # Pnnnnn for pulse dialing.
        dial T5551212 60
        if $errlvl == 0 goto msg_a
        if $errlvl == 1 goto login
        if $errlvl == 2 goto msg_b
        if $errlvl == 3 goto msg_c
        if $errlvl == 4 goto msg_d
        if $errlvl == 5 goto msg_e
        goto dial_error
login:
        # here we have the login sequence, send a CR first for
        # wake up the server, maybe this is not required.
        send \r
        # catch the server response.
        get $response $remote 20
        if $errlvl != 0 goto login_error
        # try to decide what to do next.
        if $response == login: goto senduid
        if $response != host: goto login_error
        send ppp\r
        wait login: 20
        if $errlvl != 0 goto login_error
senduid:
        send youruid\r
        wait password: 20
        if $errlvl != 0 goto login_error
        send yourpassword\r
logged:
        # if you have full dynamic IP assignment, leave the following two
        # lines as is, else fill in your IPs. $locip is local IP, $rmtip is
        # the remote IP.
        get $locip 0.0.0.0
        get $rmtip 0.0.0.0
        print Executing pppd...
        mode PPP
        exit
init_error:
        print Error, modem initialization
        quit
msg_a:
dial_error:
        print Error, unknown dialing error
        quit
msg_b:
        print Error, modem dialing error
        quit
msg_c:
        print Error, line busy
        quit
msg_d:
        print Error, no carrier
        quit
msg_e:
        print Error, no dialtone
        quit
login_error:
        print Error, host not responding to login
        quit