Date: Fri, 10 Mar 1995 22:50:53 -0800 From: rsoles@SIRIUS.COM (Roger L Soles) To: hackers@FreeBSD.org Subject: PPP Script Message-ID: <9503110644.AA08782@SIRIUS.COM>
next in thread | raw e-mail | index | archive | help
Here are some modest improvements to the FreeBSD ppp scripts -- they require
kermit, and they
should make it much simpler to maintain multiple provider configurations,
multiple modem
configurations, or first time setups...
Here are the files attached in ASCII, seperated by: >>> FILE:
>>> FILE: ppp0.faq
***NOTE***
Do not include 'AT' in any of the command below, it is provided by the
scripts.
ppp0.modem contains five lines; the first is a line
providing information about your modem manufacturer
(used by Kermit's modem command), the second is
the command to initialize your modem, the third is
the command to hang up the line (when in command
mode); the fourth is the command to place it into
auto-answer mode; the fifth is the command to reset
it
ppp0.password contains two lines; the first is the prompt your
system send when desiring you to enter your password,
the second is your password
ppp0.phonenumber contains a single line which contains all the
dialing information to reach your provider
ppp0.port contains the device name (include /dev) of to which
your modem is connected
ppp0.speed contains the speed to initiazlize your modem port
to
ppp0.username contains two lines; the first is the prompt your
system sends when desiring you to login, the
second is your login id
pppserv start ppp server
pppservdown stops ppp server
ppptest tests if ppp is running
pppup starts ppp client
pppdown stops ppp client
kermit.ans kermit modem answer script (used by pppserv)
kermit.dial kermit modem dialing script (used by pppup)
kermit.hup kermit modem hang up script
kermit.inc kermit modem script, included by others
>>> FILE: ppp0.modem
hayes
AT
&F1
H0
S0=1
Z
>>> FILE: ppp0.password
Password:
password
>>> FILE: ppp0.phonenumber
DT555.5555
>>> FILE: ppp0.port
/dev/tty01
>>> FILE: ppp0.speed
57600
>>> FILE: ppp0.username
Please login:
user
>>> FILE: pppserv
#!/bin/sh
ps ax |grep pppd |grep -v grep
pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
echo 'killing pppd, PID=' ${pid}
kill ${pid}
fi
ps ax |grep kermit |grep -v grep
pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
echo 'killing kermit, PID=' ${pid}
kill -9 ${pid}
fi
# reset ppp interface
/sbin/ifconfig ppp0 down
/sbin/ifconfig ppp0 delete
# enable autoanswer mode
kermit -y /etc/ppp/kermit.ans
# run ppp
/usr/sbin/pppd `cat /etc/ppp/ppp0.port` `cat /etc/ppp/ppp0.speed`
>>> FILE: pppservdown
#!/bin/sh
ps ax |grep pppd |grep -v grep
pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
echo 'killing pppd, PID=' ${pid}
kill ${pid}
fi
ps ax |grep kermit |grep -v grep
pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
echo 'killing kermit, PID=' ${pid}
kill -9 ${pid}
fi
/sbin/ifconfig ppp0 down
/sbin/ifconfig ppp0 delete
kermit -y /etc/ppp/kermit.noans
>>> FILE: ppptest
#!/bin/sh
pid=`ps ax| grep pppd |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
echo 'pppd running: PID=' ${pid-NONE}
else
echo 'No pppd running.'
fi
set -x
/usr/bin/netstat -n -I ppp0
/sbin/ifconfig ppp0
>>> FILE: pppup
#!/bin/sh
ps ax |grep pppd |grep -v grep
pid=`ps ax |grep pppd |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
echo 'killing pppd, PID=' ${pid}
kill ${pid}
fi
ps ax |grep kermit |grep -v grep
pid=`ps ax |grep kermit |grep -v grep|awk '{print $1;}'`
if [ "X${pid}" != "X" ] ; then
echo 'killing kermit, PID=' ${pid}
kill -9 ${pid}
fi
/sbin/ifconfig ppp0 down
/sbin/ifconfig ppp0 delete
kermit -y /etc/ppp/kermit.dial
echo
echo 'Starting ppp daemon'
/usr/sbin/pppd `cat /etc/ppp/ppp0.port` `cat /etc/ppp/ppp0.speed`
>>> FILE: kermit.ans
take /etc/ppp/kermit.inc
pau 1
out +++
inp 5 OK
out \%a\%h\13
inp 5 OK
echo \13
out \%a\%s\13
inp 5 OK
echo \13
exit
>>> FILE: kermit.dial
take /etc/ppp/kermit.inc
def \%x 0 ; login prompt counter
goto slhup
:slcmd ; put the modem in command mode
echo Put the modem in command mode.
clear ; Clear unread characters from input buffer
pause 1
output +++ ; hayes escape sequence
input 1 {OK\13\10} ; wait for OK
if success goto slhup
output \13
pause 1
output \%a\13
input 1 {OK\13\10}
if fail goto slcmd ; if modem doesn't answer OK, try again
:slhup ; hang up the phone
clear ; Clear unread characters from input buffer
pause 1
echo Hanging up the phone.
output \%a\%h\13 ; hayes command for on hook
input 2 {OK\13\10}
if fail goto slcmd ; if no OK answer, put modem in command mode
:sldial ; dial the number
pause 1
echo Dialing.
output \%a\%i\13
input 1 {OK\13\10}
output \%a\%n\13\10
clear
assign \%x 0 ; zero the time counter
:look
increment \%x ; Count the seconds
input 1 {CONNECT }
if success goto sllogin
reinput 1 {NO CARRIER\13\10}
if success goto sldial
reinput 1 {NO DIALTONE\13\10}
if success goto slnodial
reinput 1 {\255}
if success goto slhup
reinput 1 {\127}
if success goto slhup
if < \%x 60 goto look
else goto slhup
:sllogin ; login
input 1 {\13\10}
clear
pause 1
assign \%x 0 ; zero the time counter
echo
echo Looking for login prompt.
:slloop
increment \%x ; Count the seconds
clear ; Clear unread characters from input buffer
output \13
;
; put your expected login prompt here:
;
input 1 {\%l}
if success goto sluid
reinput 1 {\255}
if success goto slhup
reinput 1 {\127}
if success goto slhup
if < \%x 10 goto slloop ; try 10 times to get a login prompt
else goto slhup ; hang up and start again if 10 failures
:sluid
output \%u\13
input 1 {\%c}
output \%p\13
echo
input 1 {beginning....}
echo
quit
:slnodial
echo \7No dialtone. Check the telephone line!\7
exit 1
; local variables:
; mode: csh
; comment-start: "; "
; comment-start-skip: "; "
; end:
>>> FILE: kermit.hup
take /etc/ppp/kermit.inc
echo Sending Hangup Command
out \13
clear
out \%a\%h\13
inp 5 OK\13\10
if success goto done
:attention
echo Sending Attention String
pau 1
clear
out +++
inp 5 OK\13\10
if fail goto attention
echo Sending Hangup Command
clear
out \%a\%h\13
echo \13
:done
exit
>>> FILE: kermit.inc
;
; read port
;
open read /etc/ppp/ppp0.port
read %r
close read-file
set line \%r
;
; read speed
;
open read /etc/ppp/ppp0.speed
read %r
close read-file
set speed \%r
;
; read modem type
;
open read /etc/ppp/ppp0.modem
read %r
set modem \%r
read %a
read %i
read %h
read %s
read %r
close read-file
;
; read phone number
;
open read /etc/ppp/ppp0.phonenumber
read %n
close read-file
;
; read prompt & user name
;
open read /etc/ppp/ppp0.username
read %l
read %u
close read-file
;
; read prompt & password
;
open read /etc/ppp/ppp0.password
read %c
read %p
close read-file
set file type binary ; full 8 bit file xfer
set file names literal
set win 8
set rec pack 1024
set send pack 1024
set block 3
set term bytesize 8
set command bytesize 8
set flow none
set dial hangup off
set carrier auto ; Then SET CARRIER if necessary,
set dial display on ; Then SET DIAL if necessary,
set input echo on
set input timeout proceed
set input case ignore
//----------------------------------------------------------------------------
// Roger L Soles
// PO Box 280785
// San Francisco, CA 94124-0785
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9503110644.AA08782>
