1159720Syar.Dd June 26, 1997
2159720Syar.Dt PPPCTL 8
3159720Syar.Os
4159720Syar.Sh NAME
5159720Syar.Nm pppctl
6159720Syar.Nd PPP control program
7159720Syar.Sh SYNOPSIS
8159720Syar.Nm
9159720Syar.Op Fl v
10159720Syar.Op Fl t Ar n
11159720Syar.Op Fl p Ar passwd
12159720Syar.Xo Oo Ar host : Oc Ns
13159720Syar.Ar Port | LocalSocket
14159720Syar.Xc
15159720Syar.Oo
16159720Syar.Sm off
17159720Syar.Ar command Oo ; Ar command Oc Ar ...
18159720Syar.Sm on
19159720Syar.Oc
20159720Syar.Sh DESCRIPTION
21159720SyarThis utility provides command line control of the
22159720Syar.Xr ppp 8
23159720Syardaemon.
24159720SyarIts primary use is to facilitate simple scripts that
25159720Syarcontrol a running daemon.
26159720Syar.Pp
27159720SyarThe
28159720Syar.Nm
29159720Syarutility is passed at least one argument, specifying the socket on which
30159720Syar.Nm ppp
31159720Syaris listening.
32159720SyarRefer to the
33159720Syar.Sq set server
34159720Syarcommand of
35159720Syar.Nm ppp
36159720Syarfor details.
37159720SyarIf the socket contains a leading '/', it
38159720Syaris taken as an
39159720Syar.Dv AF_LOCAL
40159720Syarsocket.
41159720SyarIf it contains a colon, it is treated as a
42201387Sed.Ar host : Ns Ar port
43159720Syarpair, otherwise it is treated as a TCP port specification on the
44159720Syarlocal machine (127.0.0.1).
45159720SyarBoth the
46159720Syar.Ar host
47159720Syarand
48159720Syar.Ar port
49159720Syarmay be specified numerically if you wish to avoid a DNS lookup
50159720Syaror do not have an entry for the given port in
51159720Syar.Pa /etc/services .
52159720Syar.Pp
53159720SyarAll remaining arguments are concatenated to form the
54159720Syar.Ar command Ns (s)
55159720Syarthat will be sent to the
56159720Syar.Nm ppp
57159720Syardaemon.
58159720SyarIf any semi-colon characters are found, they are treated as
59159720Syar.Ar command
60delimiters, allowing more than one
61.Ar command
62in a given
63.Sq session .
64For example:
65.Bd -literal -offset indent
66pppctl 3000 set timeout 300\\; show timeout
67.Ed
68.Pp
69Do not forget to escape or quote the ';' as it is a special character
70for most shells.
71.Pp
72If no
73.Ar command
74arguments are given,
75.Nm
76enters interactive mode, where commands are read from standard input.
77When reading commands, the
78.Xr editline 3
79library is used, allowing command-line editing (with
80.Xr editrc 5
81defining editing behaviour).
82The history size
83defaults to
84.Em 20 lines .
85.Pp
86The following command line options are available:
87.Bl -tag -width Ds
88.It Fl v
89Display all data sent to and received from the
90.Nm ppp
91daemon.
92Normally,
93.Nm
94displays only non-prompt lines received.
95This option is ignored in
96interactive mode.
97.It Fl t Ar n
98Use a timeout of
99.Ar n
100instead of the default 2 seconds when connecting.
101This may be required
102if you wish to control a daemon over a slow (or even a dialup) link.
103.It Fl p Ar passwd
104Specify the password required by the
105.Nm ppp
106daemon.
107If this switch is not used,
108.Nm
109will prompt for a password once it has successfully connected to
110.Nm ppp .
111.El
112.Sh ENVIRONMENT
113The following environment variables are understood by
114.Nm
115when in interactive mode:
116.Bl -tag -width XXXXXXXXXX
117.It Dv EL_SIZE
118The number of history lines.
119The default is 20.
120.It Dv EL_EDITOR
121The edit mode.
122Only values of "emacs" and "vi" are accepted.
123Other values
124are silently ignored.
125This environment variable will override the
126.Ar bind -v
127and
128.Ar bind -e
129commands in
130.Pa ~/.editrc .
131.El
132.Sh EXAMPLES
133If you run
134.Nm ppp
135in
136.Fl auto
137mode,
138.Nm
139can be used to automate many frequent tasks (you can actually control
140.Nm ppp
141in any mode except interactive mode).
142Use of the
143.Fl p
144option is discouraged (even in scripts that are not readable by others)
145as a
146.Xr ps 1
147listing may reveal your secret.
148.Pp
149The best way to allow easy, secure
150.Nm
151access is to create a local server socket in
152.Pa /etc/ppp/ppp.conf
153(in the correct section) like this:
154.Bd -literal -offset indent
155set server /var/run/internet "" 0177
156.Ed
157.Pp
158This will instruct
159.Nm ppp
160to create a local domain socket, with srw------- permissions and no
161password, allowing access only to the user that invoked
162.Nm ppp .
163Refer to the
164.Xr ppp 8
165man page for further details.
166.Pp
167You can now create some easy-access scripts.
168To connect to the internet:
169.Bd -literal -offset indent
170#! /bin/sh
171test $# -eq 0 && time=300 || time=$1
172exec pppctl /var/run/internet set timeout $time\\; dial
173.Ed
174.Pp
175To disconnect:
176.Bd -literal -offset indent
177#! /bin/sh
178exec pppctl /var/run/internet set timeout 300\\; close
179.Ed
180.Pp
181To check if the line is up:
182.Bd -literal -offset indent
183#! /bin/sh
184pppctl -p '' -v /var/run/internet quit | grep ^PPP >/dev/null
185if [ $? -eq 0 ]; then
186  echo Link is up
187else
188  echo Link is down
189fi
190.Ed
191.Pp
192You can even make a generic script:
193.Bd -literal -offset indent
194#! /bin/sh
195exec pppctl /var/run/internet "$@"
196.Ed
197.Pp
198You could also use
199.Nm
200to control when dial-on-demand works.
201Suppose you want
202.Nm ppp
203to run all the time, but you want to prevent dial-out between 8pm and 8am
204each day.
205However, any connections active at 8pm should continue to remain
206active until they are closed or naturally time out.
207.Pp
208A
209.Xr cron 8
210entry for 8pm which runs
211.Bd -literal -offset indent
212pppctl /var/run/internet set filter dial 0 deny 0 0
213.Ed
214.Pp
215will block all further dial requests, and the corresponding 8am entry
216.Bd -literal -offset indent
217pppctl /var/run/internet set filter dial -1
218.Ed
219.Pp
220will allow them again.
221.Sh SEE ALSO
222.Xr ps 1 ,
223.Xr editline 3 ,
224.Xr editrc 5 ,
225.Xr services 5 ,
226.Xr ppp 8
227.Sh HISTORY
228The
229.Nm
230utility first appeared in
231.Fx 2.2.5 .
232