I find expect a much nicer tool to use than chat for scripts like this (and for many other things). You can get expect from . You may need the version of tcl in the same directory. Here's simple sample expect script. It works, but it could use some improvement. You can set variables for the phone number, username and password, and the logging can be improved. I originally switched to expect because it can easily handle dialing multiple different numbers for the ISP, but I later took all that code out. --------------------------cut here-------------------------- #!/usr/local/bin/expect -f log_file /var/log/isp.exp.log # If modem is hung proc modemtimedout {} { exit 1 } # If remote system times out proc timedout {} { exit 1 } set timeout 15 send AT\r expect timeout timedout OK {send AT&F1\r} expect timeout timedout OK {send ATZ\r} expect timeout timedout OK {send ATM0\r} set timeout 90 expect timeout { modemtimedout } "OK" { send "ATDT5551212\r" # What's this for? } "VCON" { send "ATDT5551212\r" } expect timeout { timedout } -re "CONNECT.*28800" { #Success } -re "CONNECT.*26400" { #Success } -re "CONNECT.*14400" { #Success } -re "CONNECT.*2400" { exit 1 } "NO CARRIER" { exit 1 } "BUSY" { exit 1 } "NO DIALTONE" { exit 1 } "ERROR" { exit 1 } set timeout 45 expect timeout timedout "name: " {send "username\r"} expect timeout timedout "word: " {send "password\r"} # What's this sleep in here for? sleep 1 expect timeout timedout "dialin>" {send "ppp default\r"} --------------------------cut here-------------------------- > -- /etc/rc.d/rc.inet1 (using private addresses on my LAN) > echo Enabling IP Masquerading > /sbin/ipfwadm -F -p deny > /sbin/ipfwadm -F -a m -S 192.168.0.0/24 -D 0.0.0.0/0 For greater security I would add to the latter line the option "-V 192.168.0.1" (replace the number by the address of the interface of your machine on the local net -- probably the address of your ethernet interface; find out what it is with "ifconfig eth0"). > # make sure http transfers hold the link for 2 minutes, even after they end. > # NOTE: Your /etc/services may not define the tcp service www, in which > # case you should comment out the following two lines or get a more > # up to date /etc/services file. See the FAQ for information on obtaining > # a new /etc/services file. > # Changed to 8 minutes --dranch > accept tcp 480 tcp.dest=tcp.www > accept tcp 480 tcp.source=tcp.www I have also added a similar rule for tcp.www-user, user level www at port 8080. I don't know if it has an official name, but many sites use 8080 for that purpose. Do it like this: accept tcp 480 tcp.dest=tcp.www-user accept tcp 480 tcp.source=tcp.www-user and add this line to /etc/services, if there isn't a similar one there already. www-user 8080/tcp I moved the ftp rules here, and also uncommented the ftp-data rules here and in /etc/services. I want ftp to behave more like www so the link doesn't go down as often when I browse ftp sites. > # Once the link is no longer live, we try to shut down the connection > # quickly. Note that if the link is already down, a state change > # will not bring it back up. > keepup tcp 60 !tcp.live > ignore tcp !tcp.live > # an ftp-data or ftp connection can be expected to show reasonably frequent > # traffic. > # Changed to 8 minutes --dranch > accept tcp 480 tcp.dest=tcp.ftp > accept tcp 480 tcp.source=tcp.ftp > #NOTE: ftp-data is not defined in the /etc/services file provided with > # the latest versions of NETKIT, so I've got this commented out here. > # If you want to define it add the following line to your /etc/services: > # ftp-data 20/tcp > # and uncomment the following two rules. > #accept tcp 120 tcp.dest=tcp.ftp-data > #accept tcp 120 tcp.source=tcp.ftp-data > -- /usr/lib/ppp/diald.isp > echo "Diald starting.." > /usr/sbin/diald /dev/ttyS1 /dev/ttyS1 lock mtu 470 debug 4 -m ppp local > 205.162.63.211 \ If you're using dynamic IP assignment, you have to be more careful about the local address you pick, even though "it doesn't matter" after the link is up. Here's what happened to me: for my local address I chose a random address from the pool of dynamic addresses. For some reason, sendmail seized on it as the address of my machine, and did a reverse lookup whenever it started, which had the effect of bringing up ppp every time local mail was sent on my machine. I solved the problem by choosing an (otherwise unused) address on my local net as the local address and adding it to /etc/hosts > remote 127.0.0.2 defaultroute modem crtscts connect '/usr/lib/ppp/chat -v I'm suspicious of the 127.0.0.2. Picking an typical remote address might be a better idea. > -t 45 > -f /etc/chat.isp' I find it a little more convenient to start diald with the command line "/usr/bin/diald /dev/ttyS1 -f /etc/diald/isp.conf", and to place all the options in /etc/diald/isp.conf: --------------------------cut here-------------------------- # # Debug options # # debug 15 accounting-log /var/log/diald.isp # # Networking options # mode ppp mtu 1500 # Add this local address to /etc/hosts and map it to your machine's name local 192.168.68.2 remote typical.remote.ip.address dynamic defaultroute # # Comm options # lock modem crtscts connect-timeout 120 # so mgetty doesn't grab the line # before diald tries again redial-timeout 4 connect /etc/diald/isp.exp ip-up /etc/diald/ip-up.sh # # Control options # pidfile isp.pid fifo /var/run/isp.ctl --------------------------cut here-------------------------- One other item: I have the following in ip-up.sh: --------------------------cut here-------------------------- #!/bin/sh # check for mail whenever the link comes up /usr/bin/uux -r mail-exchanger! /usr/lib/uucp/uucico -r1 --------------------------cut here-------------------------- This causes mail to start to transfer whenever the link comes up, which is a little nicer than waiting for it to transfer every two hours. Of course I continue to check for mail on a regular basis as well in case nothing else brings the link up (or the link stays up for a long time). Ed -- Ed Doolittle "Being on time is like being on fire."