# how to write this pppd chat script

## nivw

hi all,

I am seeking to perfect the ppd chat script used to connect to a cellular 3G , orange IL.

here is the script I got now in /etc/conf.d/net:

```

config_ppp0="ppp"

link_ppp0="/dev/ttyUSB2"

plugins_ppp0=""

username_ppp0="nobody"

password_ppp0="nothing"

pppd_ppp0="lock defaultroute noipdefault noauth usepeerdns 460800"

phone_number_ppp0="*99#"

chat_ppp0=" 

    'ABORT' 'BUSY'

    'ABORT' 'ERROR'

    'ABORT' 'NO ANSWER'

    'ABORT' 'NO CARRIER'

    'ABORT' 'NO DIALTONE'

    'ABORT' 'Invalid Login'

    'ABORT' 'Login incorrect'

    'ZEND' ''

   '' 'ATZ'

   'OK' 'AT+CPMS=\\\"SM\\\",\\\"SM\\\",\\\"\\\"'

   'OK' 'AT+CPIN?'

   'READY-AT+CPIN=1111-OK' ''

    'OK' 'AT&F &D2 &C1'

    'OK' 'ATS7=60 S30=0 S0=0'

    'OK' 'AT+CGDCONT=1,\\\"IP\\\",\\\"uinternet\\\"'

    'OK' 'ATDT\T'

    'CONNECT' ''

"

```

here is my syslog:

```
May  3 21:45:35 zahi chat[13831]: abort on (BUSY)

May  3 21:45:35 zahi chat[13831]: abort on (ERROR)

May  3 21:45:35 zahi chat[13831]: abort on (NO ANSWER)

May  3 21:45:35 zahi chat[13831]: abort on (NO CARRIER)

May  3 21:45:35 zahi chat[13831]: abort on (NO DIALTONE)

May  3 21:45:35 zahi chat[13831]: abort on (Invalid Login)

May  3 21:45:35 zahi chat[13831]: abort on (Login incorrect)

May  3 21:45:35 zahi chat[13831]: expect (ZEND)

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZDONR: "Not Found"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZPASR: "Limited Service"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZDONR: "Not Found"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZPASR: "Limited Service"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZDONR: "Not Found"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZPASR: "Limited Service"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZDONR: "Not Found"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZPASR: "No Service"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZDONR: "orange IL",425,1,"CS_ONLY","ROAM_OFF"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZPASR: "UMTS"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZDONR: "orange IL",425,1,"CS_ONLY","ROAM_OFF"^M

May  3 21:45:35 zahi chat[13831]: ^M

May  3 21:45:35 zahi chat[13831]: +ZPASR: "UMTS"^M

May  3 21:45:37 zahi chat[13831]: ^M

May  3 21:45:37 zahi chat[13831]: +ZDONR: "orange IL",425,1,"CS_PS","ROAM_OFF"^M

May  3 21:45:37 zahi chat[13831]: ^M

May  3 21:45:37 zahi chat[13831]: +ZPASR: "UMTS"^M

May  3 21:45:40 zahi chat[13831]: ^M

May  3 21:45:40 zahi chat[13831]: +ZPSTM: <number>3;1,8<another number>D8;^M

May  3 21:45:40 zahi chat[13831]: ^M

May  3 21:45:40 zahi chat[13831]: +ZEND

May  3 21:45:40 zahi chat[13831]:  -- got it

May  3 21:45:40 zahi chat[13831]: send (^M)

May  3 21:45:40 zahi chat[13831]: send (ATZ^M)

May  3 21:45:40 zahi chat[13831]: expect (OK)

May  3 21:45:40 zahi chat[13831]: ^M

May  3 21:45:40 zahi chat[13831]: ^M

May  3 21:45:40 zahi chat[13831]: +ZEND^M

May  3 21:45:40 zahi chat[13831]: ATZ^M^M

May  3 21:45:40 zahi chat[13831]: OK

May  3 21:45:40 zahi chat[13831]:  -- got it

May  3 21:45:40 zahi chat[13831]: send (AT+CPMS=\"SM\",\"SM\",\"\"^M)

May  3 21:45:40 zahi chat[13831]: expect (OK)

May  3 21:45:40 zahi chat[13831]: ^M

May  3 21:45:40 zahi chat[13831]: AT+CPMS="SM","SM",""^M^M

May  3 21:45:40 zahi chat[13831]: +CPMS: 0,20,0,20,0,100^M

May  3 21:45:40 zahi chat[13831]: ^M

May  3 21:45:40 zahi chat[13831]: OK

May  3 21:45:40 zahi chat[13831]:  -- got it

May  3 21:45:40 zahi chat[13831]: send (AT+CPIN?^M)

May  3 21:45:41 zahi chat[13831]: expect (READY)

May  3 21:45:41 zahi chat[13831]: ^M

May  3 21:45:41 zahi chat[13831]: AT+CPIN?^M^M

May  3 21:45:41 zahi chat[13831]: +CPIN: READY

May  3 21:45:41 zahi chat[13831]:  -- got it

May  3 21:45:41 zahi chat[13831]: send (^M)

May  3 21:45:41 zahi chat[13831]: expect (OK)

May  3 21:45:41 zahi chat[13831]: ^M

May  3 21:45:41 zahi chat[13831]: ^M

May  3 21:45:41 zahi chat[13831]: OK

May  3 21:45:41 zahi chat[13831]:  -- got it

May  3 21:45:41 zahi chat[13831]: send (AT&F &D2 &C1^M)

May  3 21:45:41 zahi chat[13831]: expect (OK)

May  3 21:45:41 zahi chat[13831]: ^M

May  3 21:45:41 zahi chat[13831]: AT&F &D2 &C1^M^M

May  3 21:45:41 zahi chat[13831]: OK

May  3 21:45:41 zahi chat[13831]:  -- got it

May  3 21:45:41 zahi chat[13831]: send (ATS7=60 S30=0 S0=0^M)

May  3 21:45:41 zahi chat[13831]: expect (OK)

May  3 21:45:41 zahi chat[13831]: ^M

May  3 21:45:41 zahi chat[13831]: ATS7=60 S30=0 S0=0^M^M

May  3 21:45:41 zahi chat[13831]: OK

May  3 21:45:41 zahi chat[13831]:  -- got it

May  3 21:45:41 zahi chat[13831]: send (AT+CGDCONT=1,\"IP\",\"uinternet\"^M)

May  3 21:45:42 zahi chat[13831]: expect (OK)

May  3 21:45:42 zahi chat[13831]: ^M

May  3 21:45:42 zahi chat[13831]: AT+CGDCONT=1,"IP","uinternet"^M^M

May  3 21:45:42 zahi chat[13831]: OK

May  3 21:45:42 zahi chat[13831]:  -- got it

May  3 21:45:42 zahi chat[13831]: send (ATDT*99#^M)

May  3 21:45:42 zahi chat[13831]: expect (CONNECT)

May  3 21:45:42 zahi chat[13831]: ^M

May  3 21:45:42 zahi chat[13831]: ATDT*99#^M

May  3 21:45:42 zahi chat[13831]: CONNECT

May  3 21:45:42 zahi chat[13831]:  -- got it

May  3 21:45:42 zahi chat[13831]: send (^M)

May  3 21:45:42 zahi pppd[13805]: Serial connection established.

May  3 21:45:42 zahi pppd[13805]: Using interface ppp0

May  3 21:45:42 zahi pppd[13805]: Connect: ppp0 <--> /dev/ttyUSB2

May  3 21:45:43 zahi pppd[13805]: CHAP authentication succeeded

May  3 21:45:43 zahi pppd[13805]: CHAP authentication succeeded

```

however this may also happen:

```
May  3 21:41:48 zahi pppd[13127]: Connect script failed

May  3 21:42:21 zahi chat[13160]: abort on (BUSY)

May  3 21:42:21 zahi chat[13160]: abort on (ERROR)

May  3 21:42:21 zahi chat[13160]: abort on (NO ANSWER)

May  3 21:42:21 zahi chat[13160]: abort on (NO CARRIER)

May  3 21:42:21 zahi chat[13160]: abort on (NO DIALTONE)

May  3 21:42:21 zahi chat[13160]: abort on (Invalid Login)

May  3 21:42:21 zahi chat[13160]: abort on (Login incorrect)

May  3 21:42:21 zahi chat[13160]: expect (ZEND)

May  3 21:42:21 zahi chat[13160]: ^M

May  3 21:42:21 zahi chat[13160]: +ZUSIMR:2^M

May  3 21:42:21 zahi chat[13160]: ^M

May  3 21:42:21 zahi chat[13160]: +ZUSIMR:2^M

May  3 21:42:21 zahi chat[13160]: ^M

May  3 21:42:21 zahi chat[13160]: +ZUSIMR:2^M

May  3 21:42:21 zahi chat[13160]: ^M

```

I didnt want this code as it will abort then work only the second time around:

```
chat_ppp0="

        'ABORT' 'BUSY'

        'ABORT' 'NO ANSWER'

        'ABORT' 'NO CARRIER'

        'ABORT' 'NO DIALTONE'

        'ABORT' 'Invalid Login'

        'ABORT' 'Login incorrect'

        'TIMEOUT' '5'

        '' 'ATZ'

        'OK' 'AT+CPIN?'

        'READY-AT+CPIN=1234-OK' ''

        'OK' 'ATQ0 V1 E1 S0=0 &C1 &D2 +FCLASS=0'

        'OK' 'AT+CGDCONT=1,\\\"IP\\\",\\\"uinternet\\\"'

        'OK' 'ATDT\T'

        'CONNECT' ''

        '~--' ''

"

```

I am reffering to the line with '' 'ATZ'

----------

## erik258

Hi!  What network are you attaching to?  

I've been doing this a little differently, calling pppd directly rather than using initscripts, but here's my pppd files, which work interchangeably on Verizon and Sprint.  

```
ttyUSB0

921600

debug

noauth

defaultroute

usepeerdns

holdoff 2

connect-delay 2000

user 9876543210@vzw3g.com

show-password

persist

maxfail 0

ipcp-accept-local

ipcp-accept-remote

lcp-echo-failure 4

lcp-echo-interval 65535

connect '/usr/sbin/chat -v -t5 -f /etc/ppp/peers/verizon_chat'

```

```
ABORT 'NO DIAL TONE' ABORT 'NO ANSWER' ABORT 'NO CARRIER' ABORT DELAYED

SAY 'Initializing modem\n'

'' AT

OK ATZ

SAY '\n'

SAY     'Dialing...\n'

OK ATDT#777

CONNECT ''
```

I tweaked those scripts for inter-tower roaming, and they seem to work pretty well for that.  

You seem to be doing a lot more than me in your scirpts; this may be necessary to connect to your provider.  Or, it might be the cause of your problems.  

Further, it seems as though you're doing a lot of extra quoting in your connect and chat scripts within /etc/conf.d/net.  But, since you have more experience already with ppp + conf.d/net,  I just point it out as an observation. 

Anyhow, I would think it might be wise to try doing this manually first, and then setting up conf.d/net to take care of it for you only once you know the chat and connect scripts are proper.  

To do so, you simply need to execute the following command: 

```
sudo pppd call verizon
```

In your case, you'd want to exchange 'verizon' with the name of your script in /etc/ppp/peers.  The chat script will be referenced by this script.  

Hope it helps!

----------

