图: 示例 dip 脚本
# Sample dip script for dialing up cowslip
# Set local and remote name and address
get $local vlager
get $remote cowslip
port cua3 # choose a serial port
speed 38400 # set speed to max
modem HAYES # set modem type
reset # reset modem and tty
flush # flush out modem response
# Prepare for dialing.
send ATQ0V1E1X1\r
wait OK 2
if $errlvl != 0 goto error
dial 0123456789
if $errlvl != 0 goto error
wait CONNECT 60
if $errlvl != 0 goto error
# Okay, we're connected now
sleep 3
send \r\n\r\n
wait ogin: 10
if $errlvl != 0 goto error
send Cvlager\r
wait ssword: 5
if $errlvl != 0 goto error
#better not leave your password in ascii (thanx noud)
password
wait running 30
if $errlvl != 0 goto error
#to set up your remote and local IP
get $remote remote
print remote = $remote
if $errlvl != 0 goto error
wait to 3
get $local remote
print local = $local
if $errlvl != 0 goto error
# We have logged in, and the remote side is firing up CSLIP.
print Connected to $remote with address $rmtip
default # Make this link our default route
mode CSLIP # We go to CSLIP mode, too
# fall through in case of error
error:
print CSLIP to $remote failed.
图
中展示了一个示例脚本。它可以通过调用 dip 并将脚本名称作为参数来连接到 cowslip
# dip cowslip.dip
DIP: Dialup IP Protocol Driver version 3.3.7 (12/13/93)
Written by Fred N. van Kempen, MicroWalt Corporation.
connected to cowslip.moo.com with addr 193.174.7.129
#
连接到 cowslip 并启用 CSLIP 后,dip 将从终端分离并转到后台运行。然后您就可以开始在 CSLIP 链路上使用正常的网络服务。要终止连接,只需使用 -k 选项调用 dip 即可。这会向 dip 进程发送一个挂断信号,进程 ID 记录在 /etc/dip.pid 中:
# kill -k在 dip 的脚本语言中,以美元符号开头的关键字表示变量名。 dip 有一组预定义的变量,将在下面列出。例如,$remote 和 $local 包含 SLIP 链路中涉及的本地和远程主机的主机名。
示例脚本中的前两条语句是 get 命令,这是 dip 设置变量的方式。在这里,本地和远程主机名分别设置为 vlager 和 cowslip。
接下来的五个语句设置终端线路和调制解调器。 reset 命令向调制解调器发送复位字符串;对于 Hayes 兼容的调制解调器,这是 ATZ 命令。 下一条语句清空调制解调器的响应,以便接下来几行的登录对话可以正常工作。 这个对话非常直接:它只是拨打 cowslip 的电话号码 41988,并使用密码 hey-jude 登录到 Svlager 帐户。 wait 命令使 dip 等待以其第一个参数给出的字符串;作为第二个参数给出的数字使等待在那么多秒后超时(如果未收到这样的字符串)。 穿插在登录过程中的 if 命令检查在执行命令时是否发生错误。
登录后执行的最后命令是 default,它使 SLIP 链路成为所有主机的默认路由,以及 mode,它在线路上启用 SLIP 模式,并为您配置接口和路由表。