67、UNIX 系统中的调制解调器控制与通信软件使用指南

UNIX调制解调器控制与通信指南

UNIX 系统中的调制解调器控制与通信软件使用指南

1. 调制解调器连接问题与 UNIX 系统关注点

在某些情况下,当两个系统都发送登录提示时,连接可能永远无法建立。两个系统会相互反复发送登录和密码消息,使连接陷入一种“致命拥抱”的状态。

在 UNIX 系统中,调制解调器并非核心关注点。随着网络的蓬勃发展,UNIX 与网络成功融合,调制解调器的地位逐渐边缘化。UNIX 专注于提供基本网络服务,网络连接成为每个 UNIX 系统不可或缺的一部分。调制解调器在桌面端更具吸引力,而 UNIX 在桌面端并不占主导地位。不过,这并不意味着 UNIX 完全忽视了调制解调器相关主题,每个 UNIX 版本都提供了某种调制解调器控制功能,这也为第三方开发者提供了填补现有空白的机会,他们开发的软件在所有 UNIX 平台上广泛应用。

2. UNIX 调制解调器控制方法

由于缺乏通用的 UNIX 调制解调器控制方法,出现了许多特定版本的解决方案。下面我们将介绍三种主要的方法。

2.1 终端线路与调制解调器控制

这种方法可能已成为历史,但有助于理解将通用双向调制解调器连接到专用串行终端线路时的冲突情况。需要注意的是,障碍并非在于使用的串行端口(硬件本身支持双向串行通信),而是现有的控制软件,主要是系统启动时在终端线路上调用的 getty 程序。

不同的 UNIX 版本提供了不同的解决方案:
- SunOS :具有允许串行端口双向使用的机制,驱动程序支持两个入口点,每个方向一个。对于由设备 tty0 - tty127 标识的每个终端线路,现有驱动程序会监控 DCD(数据载波检测)信号并启动 getty 程序。次要编号为 128 - 255 的设备(通常命名为 cu0 - cu127)引用相同的物理设备,但即使 DCD 信号不存在也允许打开设备。管理员需要为连接调制解调器的终端线路创建两个不同的特殊文件:用于拨入的 /dev/ttydn(n 为调制解调器线路号)和用于拨出的 /dev/cuan。这两个特殊文件仅在次要设备编号上有所不同,偏移量为 128。创建特殊文件的示例命令如下:

# mknod /dev/ttyd1 c 12 1
# mknod /dev/cua1  c 12 129

在 /etc/ttytab 中,终端线路的相应条目应替换为:

# The following entries represent the same physical modem
ttyd1  "/usr/etc/getty d2400"  unknown on  # dialin entry (enabled)
cua1   none                    unknown off # dialout entry (disabled)

最后,需要禁用拨出端口的“软件载波检测”:

#ttysoftcar n /dev/cua1

SunOS 提供了名为 zs 的手册页,用于更详细的解释和完整的安装说明。
- System V UNIX 版本 :通过 /etc/inittab 文件指定终端线路(即串行端口)的初始化。当调制解调器连接到系统时,需要为相应端口启用双工通信。可以通过将 inittab 条目中的 getty 程序替换为另一个支持 getty 和双工通信的更复杂程序(如 uugetty)来实现。例如,inittab 条目可以是:

27:2:respawn:/usr/lib/uucp/uugetty -r tty12 2400

另一种方法是调用 init 程序,使用不同的 init 运行级别(如 2 和 3)重新初始化终端线路以进行拨入和拨出。调用 #init 2 将初始化终端线路以进行拨入,包括 getty 程序;调用 #init 3 将启用终端线路以进行拨出。

2.2 与调制解调器相关的 UNIX 命令

没有统一的 UNIX 调制解调器相关命令集,这些命令通常是特定版本的。大多数 UNIX 版本会提及 uugetty 命令,但该命令主要用于其他目的。以下是一些其他命令的简要介绍:

2.2.1 cu 命令

cu 命令用于呼叫另一个 UNIX 系统、终端或可能的非 UNIX 系统,例如在 Solaris 和 HP - UX 版本中存在该命令。它管理交互式对话并可能进行文件传输。可以将 cu 命令的操作分为两个阶段:
1. 连接阶段 :建立连接。
2. 对话阶段 :进行交互。

命令格式为:

cu options { telno /systemname }

cu 命令接受许多选项,以下是一些常见选项的含义:
| 选项 | 含义 |
| ---- | ---- |
| -c device | 强制 cu 使用 /etc/uucp/Devices 文件中与用户指定设备匹配的配置条目。 |
| -s speed | 指定传输速度,默认值为“Any”,取决于 /etc/uucp/Devices 文件。 |
| -l line | 指定用作通信线路的设备名称,结合其他选项可能还依赖于 UUCP 配置文件。最常见的情况是指定的设备是直接连接的异步线路(如 /dev/term/a)。如果指定的设备与自动拨号器关联,则必须提供电话号码。 |
| -b bits | 指定线路上处理的位数(7 或 8),允许不同字符大小的系统之间进行连接。默认情况下,线路的字符大小设置为与当前本地终端相同。 |
| telno | 使用自动拨号器时,指定电话号码;等号“=”表示二次拨号音,减号“-”适当放置表示 4 秒延迟。 |
| systemname | 指定系统名称,可替代电话号码使用。在这种情况下,cu 将从 UUCP 系统文件中获取适当的直接线路或电话号码。 |

以下是一些使用示例:
- 以 2400 波特率拨打电话号码为 9 - 1 - 212 - 567 - 1234 的系统(9 之后有拨号音):

# cu -s 2400 9 =12125671234
  • 登录通过直接线路连接的系统:
# cu -l /dev/term/b
  • 以特定线路和速度拨打系统:
# cu -s 1200 -l term/b
  • 使用系统名称:
# cu systemname
2.2.2 tip 命令

tip 命令(或实用程序)用于连接到远程系统并建立全双工终端连接。连接建立后,使用 tip 的远程会话就像在本地终端上进行交互式会话一样。该命令是 Solaris 版本特有的。

命令格式为:

tip [ -v ] [ -speed-entry ] { hostname | phone-number | device }

远程文件包含描述远程系统和 tip 使用的线路速度的条目。每个主机都有默认的连接波特率,或者可以在 -speed - entry 选项中指定速度。当指定电话号码时,tip 会在远程文件中查找相应的条目以设置连接速度。当指定设备时,tip 会尝试使用用户的访问权限打开该设备。tip 会将以斜杠字符“/”开头的任何字符串解释为设备名称。建立连接时,tip 会向远程系统发送连接消息,该消息的默认值可以在远程文件中找到。tip 启动时,会从用户主目录中的 .tiprc 文件读取命令。

此外,还有一些其他的 UNIX 命令,如 Solaris 版本的 ttymon 和 ttyadm 用于控制串行线路,Linux 版本的 mgetty 或 agetty 也有相同的用途。

3. 第三方通信软件

第三方软件部分填补了 UNIX 调制解调器全面控制方面的空白。大多数此类软件可在不同的 UNIX 版本中使用,有些是免费的,有些甚至随操作系统一起分发。下面我们将重点介绍 C - Kermit 程序。

3.1 C - Kermit

Kermit 是哥伦比亚大学开发的一系列文件传输、管理和通信软件程序(称为 C - Kermit),适用于大多数计算机和操作系统。UNIX 版本的 Kermit 支持串行连接(直接或拨号)和 TCP/IP 连接。C - Kermit 可以被视为 cu、tip、uucp、ftp 和 telnet 的用户友好且强大的替代方案,它是一个用于网络和串行通信的单一软件包,提供了自动化、便利性和其他软件包所没有的语言功能。它完全支持调制解调器拨号、文件传输和管理、终端连接、字符集转换和脚本编程。

C - Kermit 有两种使用模式:
1. 远程模式 :C - Kermit 通过直接串行连接、拨号调制解调器或建立网络连接与另一台计算机建立连接。
2. 本地模式 :C - Kermit 使用实际终端、模拟器或 UNIX 工作站终端窗口或控制台驱动程序为特定终端仿真提供与远程计算机的终端连接。

C - Kermit 有两种类型的命令:
1. 熟悉的 UNIX 风格命令行选项
2. 交互式对话框 :提供一个小而有用的 C - Kermit 功能子集,用于终端连接和文件传输,还支持将文件管道输入或输出到 C - Kermit 进行传输。它还提供对拨号、脚本编程、字符集转换的访问,以及对 C - Kermit 所有功能的详细控制和显示。交互式命令也可以收集到命令文件或宏中。

启动 C - Kermit 的命令格式为:

kermit [command - file] [options…]

选项中包含一组所谓的动作选项,需要完成特定的操作。如果命令行上没有动作选项,C - Kermit 将以交互式命令模式启动,显示问候消息和“C - Kermit>”提示。如果在命令行上指定了动作选项,C - Kermit 将执行指定的操作,然后直接返回 UNIX。无论哪种方式,C - Kermit 在执行其他命令之前都会执行其初始化文件 ckermit.ini(通常位于 /usr/share/lib/kermit 目录中)中的命令,除非明确请求替代初始化。

C - Kermit 是一个功能强大且通用的程序,包含许多用于以下方面的命令:
- 程序管理
- 连接建立和释放
- 终端连接
- 文件传输
- 文件管理
- 客户端/服务器操作
- 脚本编程

大量的现有选项可以分为以下几类:
- 动作选项 :如连接、发送/接收文件、进入/终止服务器模式等。
- 设置选项 :更详细地指定文件传输、连接过程等涉及的不同 Kermit 参数。
- 其他选项 :如跳过/替代初始化、前台、后台、强制停留、显式交互、远程或调试模式等。

以下是 C - Kermit 文件传输的常见步骤:
1. 在本地计算机上启动 C - Kermit 并建立与远程计算机的连接:
- 设置调制解调器类型: SET MODEM TYPE modem - name
- 设置线路设备: SET LINE device - name
- 设置传输速度: SET SPEED bits - per - second
- 如果使用拨号,指定电话号码: DIAL phone - number
- 对于网络连接,设置网络类型和主机名或地址: SET NETWORK network - type SET HOST host - name - or - address
2. 设置其他必要的通信参数,如奇偶校验、双工和流控制。
3. 发出 CONNECT 命令。
4. 登录到远程计算机。
5. 在远程计算机上启动 C - Kermit,为文件、通信或协议相关参数发出所需的 SET 命令。如果要传输二进制文件,在发送端将 C - Kermit 程序的 SET FILE TYPE BINARY
6. 要传输文件或文件组,在本地 C - Kermit 中发出 SEND 命令,后跟文件名或通配符文件规范,例如:

send filename.txt # (send one file)
send filename.* # (send a group of files)
  1. 要接收文件,在远程 C - Kermit 中发出 RECEIVE 命令。发送和接收的 C - Kermit 将交换每个文件的名称和其他属性。
  2. 返回到本地计算机上的 C - Kermit 程序以获取本地 Kermit 程序的提示。
  3. 要传输二进制文件,向发送文件的 Kermit 程序发出 SET FILE TYPE BINARY 命令。
  4. 要接收文件,告诉本地 C - Kermit 程序执行 RECEIVE 命令;要传输文件,告诉本地 C - Kermit 程序执行 SEND 命令,指定文件名或通配符文件规范。
  5. 传输完成后,发出 CONNECT 命令再次与远程计算机上的 C - Kermit 通信。输入 EXIT 返回到远程计算机的命令提示符。完成所有操作后,注销,必要时返回到本地计算机上的 Kermit。然后可以建立另一个连接,或从本地 C - Kermit 程序退出。

为了提高文件传输性能,可以使用以下命令:
- SET RECEIVE PACKET - LENGTH 增加数据包长度。
- SET WINDOW 增加数据包窗口大小。
- SET PREFIXING 减少控制字符前缀的开销。
也可以尝试使用 FAST 命令一次性启用所有这些性能选项。在串行连接中,如果可用,建议使用硬件流控制( SET FLOW RTS/CTS )而不是软件(XON/XOFF)流控制。

以下是使用 C - Kermit 的两个示例:
- 远程模式示例 :以窗口大小为 4 的二进制模式发送文件 “filename.bin”:

kermit -v 4 -i -s filename.bin
  • 本地模式示例 :通过设备 /dev/tty0p0 建立 19200 bps 的直接连接:
kermit -l /dev/tty0p0 -b 19200 -c -r -n

如果要进行拨号,需要指定调制解调器类型并使用不同的设备名称:

kermit -m hayes -l /dev/cul0p0 -b 2400 -c -r –n

最后,我们来看一个复杂的实际示例,任务是每天定期将数据从 UNIX 系统传输到公告板站点。可用资源包括局域网中的 16 线路调制解调器池(调制解调器服务器)和公共电话网络,UNIX 系统通过局域网访问调制解调器池。解决方案如下:
1. 待传输的数据已准备好并保存在文件 “FileToGo” 中。
2. 动态创建“take - file”,以反映调制解调器线路的实际环境和状态。
3. 调用 C - Kermit 程序,使用“take - file”进行初始化。
4. 从 UNIX 系统向公告板站点传输文件,并显示详细消息。

以下是实现该任务的脚本 “bbkermit.ksh”:

#!/bin/ksh
#
# This script modifies kermit take - file, and accomplishes the transfer of the file
# FileToGo to the bulletin - board site via 24 - port modem - pool. The modified
# kermit take - file consists of two major part: modem - pool specific part dynamically
# specified within this script, and static site specific part specified in the file "bbsite.ini",
# and passed as an argument to this script. To fully understand this script a basic
# knowledge of C - Kermit is supposed. All path and file names are arbitrary
# Define global variables
CKERMIT=/share/local/c - kermit/bin/kermit  # C - Kermit executable
ZMDIR=/share/local/zmodem/bin             # zmodem executables directory
mpool=mpoolhost                           # actual modem - pool host name
user=modpool                              # actual modem - pool user ID
password=abc48fgh                         # actual modem - pool password
min_port= 2000                            # starting modem - pool port number
max_port= 2024                            # ending modem - pool port number
# Define a usage statement function
function show_usage {
    echo "Usage: bbkermit.ksh <takefile>"
}
# Check usage
if [ $# -lt 1 ]; then
    show_usage
fi
takefile=$1
# Check specified file
if [ ! -f "$takefile" ]; then
    echo "Error: Cannot read file '$takefile'"
    exit 1
fi
# Create a temporary file that can only be read by the current user
# This file will keep final kermit take - file data
TMPFILE=/tmp/bbkermit.$$
touch $TMPFILE
chmod 600 $TMPFILE
# Create the final 'take' file for kermit dynamically
# The "here document" specifies a sequence of C - Kermit
# commands for the final kermit take - file
cat << !EOF > $TMPFILE
########### Start of the here document ##############
# Setup the paths and macros for the zmodem executables
# All zmodem executables named sz, sb, sx, csz, csb and csx,
# as well as rz, rb, rx, crz, crb and crx reside in this directory
define %t $ZMDIR
# Setup send macro definitions
define sz if = \v(argc) 1 end 1 {sz what file(s)?}, -
redirect %t/csz %1 %2 %3 %4 %5 %6 %7 %8 %9
define sb if = \v(argc) 1 end 1 {sb what file(s)?}, -
redirect %t/csb %1 %2 %3 %4 %5 %6 %7 %8 %9
define sx if = \v(argc) 1 end 1 {sx what file?}, -
redirect %t/csx %1 %2 %3 %4 %5 %6 %7
# Setup receive macro definitions
define rz redirect %t/crz
define rb redirect %t/crb
define rx if = \v(argc) 1 end 1 {rx what file?}, -
redirect %t/crx %1
# Define the starting modem - pool port number
define %p $min_port
# This is the reference starting point to acquire a free modem - pool port
:ACQUIRE_MODEM
# Clear the line (Only needed for multiple passes through this loop)
hangup
# Increment the port (%p) by one (The real starting port is 2001)
assign %p \Feval(%p + 1)
# If we've tried all the ports and can't get in, then just exit
if > %p $max_port exit 1
# Attempt to connect to the specified port
echo Attempting to connect on port %p
telnet $mpool %p
# If port is in use, then jump back up to :ACQUIRE_MODEM and try the next port
if failure goto ACQUIRE_MODEM
# Log into modem - pool
input 5 sername:
if failure goto ACQUIRE_MODEM
# Enter userid and password
output $user\13
input 5 assword:
if failure goto ACQUIRE_MODEM
# To prevent the appearance of the clear password in the take - file
# the password itself is previously saved in the kermit variable "\%w"
output %w\13
sleep 3
# Check that modem is responding
output AT\13
input 5 OK if failure goto ACQUIRE_MODEM
!EOF
########### End of the here document ##############
# Add the user specified take - file onto the end of the temporary file
cat $takefile >> $TMPFILE
if [ $? -ne 0 ]; then
    rm $TMPFILE
    exit 1
fi
# Run kermit using TMPFILE as a final take - file. The password is
# define here, so that it won't show up in the temporary file.
$CKERMIT << !EOF
define %w $password
take $TMPFILE
!EOF
# Remove tempfile
rm -f $TMPFILE

该脚本动态指定所谓的“take - file”,然后调用 C - Kermit 程序,该程序使用创建的“take - file”进行初始化。创建的“take - file”由两部分组成:脚本中动态创建的与调制解调器池相关的部分和传递的文件 bbkermit.init 中指定的与公告板特定的静态部分。这个脚本和 bbkermit.ini 文件对应于特定的 C - Kermit 实现,但可以很容易地用作其他类似实现的模板。

综上所述,UNIX 系统在调制解调器控制方面有多种方法和工具可供选择,无论是使用系统自带的命令还是第三方软件,都能满足不同的需求。通过合理运用这些方法和工具,用户可以实现高效的调制解调器通信和文件传输。

UNIX 系统中的调制解调器控制与通信软件使用指南(续)

4. 方法总结与对比

为了更清晰地了解不同的调制解调器控制方法和通信软件的特点,我们对前面介绍的内容进行总结和对比。

4.1 终端线路与调制解调器控制方法对比
系统版本 控制方式 优势 劣势
SunOS 通过创建不同特殊文件和配置 /etc/ttytab,监控 DCD 信号 允许串行端口双向使用,可灵活进行拨入和拨出操作 配置相对复杂,需要创建多个特殊文件并进行相应设置
System V UNIX 版本 通过 /etc/inittab 文件指定初始化,可替换 getty 程序或使用不同 init 运行级别 可根据不同运行级别灵活配置拨入和拨出 对 init 运行级别的理解和配置要求较高
4.2 与调制解调器相关的 UNIX 命令对比
命令 功能 适用系统 优势 劣势
cu 呼叫其他系统,管理交互式对话和文件传输 Solaris、HP - UX 等 可通过多种选项灵活配置连接和传输参数 选项较多,需要一定学习成本
tip 连接远程系统,建立全双工终端连接 Solaris 建立连接后操作类似本地终端交互,使用方便 仅适用于 Solaris 系统,通用性较差
4.3 第三方通信软件(C - Kermit)与 UNIX 命令对比
类型 功能特点 优势 劣势
UNIX 命令(cu、tip 等) 针对特定系统版本,实现基本的调制解调器连接和通信功能 系统自带,使用方便 功能相对单一,缺乏自动化和脚本编程能力
C - Kermit 支持串行和网络连接,具备文件传输、管理、脚本编程等多种功能 功能强大,可自动化操作,跨平台性好 学习曲线较陡,配置复杂
5. 实际应用场景分析

在不同的实际应用场景中,选择合适的调制解调器控制方法和通信软件至关重要。以下是一些常见场景及对应的推荐方案。

5.1 简单的点对点连接

如果只是需要在两台计算机之间进行简单的连接和文件传输,且计算机运行的是 Solaris 或 HP - UX 系统,可以考虑使用 cu 命令。操作步骤如下:
1. 确定传输速度和目标系统信息。
2. 根据需要选择合适的选项,例如:

# 以 2400 波特率拨打电话号码为 9 - 1 - 212 - 567 - 1234 的系统(9 之后有拨号音)
# cu -s 2400 9 =12125671234
  1. 进行连接和文件传输操作。
5.2 远程终端访问

如果需要建立全双工终端连接,访问远程系统,且系统为 Solaris 版本,tip 命令是不错的选择。操作步骤如下:
1. 确定目标系统的主机名、电话号码或设备名称。
2. 输入 tip 命令并指定相应参数,例如:

# tip [ -v ] [ -speed-entry ] { hostname | phone-number | device }
  1. 建立连接后即可进行远程操作。
5.3 复杂的文件传输和自动化任务

对于需要进行大量文件传输、实现自动化操作的场景,C - Kermit 是首选。例如,每天定期将数据从 UNIX 系统传输到公告板站点的任务,具体操作步骤如下:

graph LR
    A[准备待传输数据,保存为 FileToGo] --> B[动态创建 take - file]
    B --> C[调用 C - Kermit 程序,使用 take - file 初始化]
    C --> D[进行文件传输,显示详细消息]
    D --> E[传输完成,清理临时文件]
  1. 准备待传输的数据并保存为 “FileToGo”。
  2. 运行 “bbkermit.ksh” 脚本,该脚本会动态创建“take - file”,并调用 C - Kermit 程序进行初始化和文件传输。脚本内容如下:
#!/bin/ksh
#
# This script modifies kermit take - file, and accomplishes the transfer of the file
# FileToGo to the bulletin - board site via 24 - port modem - pool. The modified
# kermit take - file consists of two major part: modem - pool specific part dynamically
# specified within this script, and static site specific part specified in the file "bbsite.ini",
# and passed as an argument to this script. To fully understand this script a basic
# knowledge of C - Kermit is supposed. All path and file names are arbitrary
# Define global variables
CKERMIT=/share/local/c - kermit/bin/kermit  # C - Kermit executable
ZMDIR=/share/local/zmodem/bin             # zmodem executables directory
mpool=mpoolhost                           # actual modem - pool host name
user=modpool                              # actual modem - pool user ID
password=abc48fgh                         # actual modem - pool password
min_port= 2000                            # starting modem - pool port number
max_port= 2024                            # ending modem - pool port number
# Define a usage statement function
function show_usage {
    echo "Usage: bbkermit.ksh <takefile>"
}
# Check usage
if [ $# -lt 1 ]; then
    show_usage
fi
takefile=$1
# Check specified file
if [ ! -f "$takefile" ]; then
    echo "Error: Cannot read file '$takefile'"
    exit 1
fi
# Create a temporary file that can only be read by the current user
# This file will keep final kermit take - file data
TMPFILE=/tmp/bbkermit.$$
touch $TMPFILE
chmod 600 $TMPFILE
# Create the final 'take' file for kermit dynamically
# The "here document" specifies a sequence of C - Kermit
# commands for the final kermit take - file
cat << !EOF > $TMPFILE
########### Start of the here document ##############
# Setup the paths and macros for the zmodem executables
# All zmodem executables named sz, sb, sx, csz, csb and csx,
# as well as rz, rb, rx, crz, crb and crx reside in this directory
define %t $ZMDIR
# Setup send macro definitions
define sz if = \v(argc) 1 end 1 {sz what file(s)?}, -
redirect %t/csz %1 %2 %3 %4 %5 %6 %7 %8 %9
define sb if = \v(argc) 1 end 1 {sb what file(s)?}, -
redirect %t/csb %1 %2 %3 %4 %5 %6 %7 %8 %9
define sx if = \v(argc) 1 end 1 {sx what file?}, -
redirect %t/csx %1 %2 %3 %4 %5 %6 %7
# Setup receive macro definitions
define rz redirect %t/crz
define rb redirect %t/crb
define rx if = \v(argc) 1 end 1 {rx what file?}, -
redirect %t/crx %1
# Define the starting modem - pool port number
define %p $min_port
# This is the reference starting point to acquire a free modem - pool port
:ACQUIRE_MODEM
# Clear the line (Only needed for multiple passes through this loop)
hangup
# Increment the port (%p) by one (The real starting port is 2001)
assign %p \Feval(%p + 1)
# If we've tried all the ports and can't get in, then just exit
if > %p $max_port exit 1
# Attempt to connect to the specified port
echo Attempting to connect on port %p
telnet $mpool %p
# If port is in use, then jump back up to :ACQUIRE_MODEM and try the next port
if failure goto ACQUIRE_MODEM
# Log into modem - pool
input 5 sername:
if failure goto ACQUIRE_MODEM
# Enter userid and password
output $user\13
input 5 assword:
if failure goto ACQUIRE_MODEM
# To prevent the appearance of the clear password in the take - file
# the password itself is previously saved in the kermit variable "\%w"
output %w\13
sleep 3
# Check that modem is responding
output AT\13
input 5 OK if failure goto ACQUIRE_MODEM
!EOF
########### End of the here document ##############
# Add the user specified take - file onto the end of the temporary file
cat $takefile >> $TMPFILE
if [ $? -ne 0 ]; then
    rm $TMPFILE
    exit 1
fi
# Run kermit using TMPFILE as a final take - file. The password is
# define here, so that it won't show up in the temporary file.
$CKERMIT << !EOF
define %w $password
take $TMPFILE
!EOF
# Remove tempfile
rm -f $TMPFILE
  1. 传输完成后,脚本会自动清理临时文件。
5. 注意事项与优化建议

在使用上述方法和工具时,还需要注意以下事项,并可以根据实际情况进行优化。

5.1 配置文件备份

在进行任何配置更改之前,务必备份相关的配置文件,如 /etc/ttytab、/etc/inittab 等。这样在出现问题时可以及时恢复到之前的配置状态。例如,使用以下命令备份 /etc/ttytab 文件:

cp /etc/ttytab /etc/ttytab.backup
5.2 权限管理

确保用户对相关文件和设备具有足够的访问权限。例如,在使用 C - Kermit 进行文件传输时,要保证用户对传输的文件和使用的设备有读写权限。可以使用以下命令更改文件权限:

chmod 644 filename.txt
5.3 性能优化

对于 C - Kermit 文件传输,可以通过设置相关参数来提高性能。例如,使用以下命令增加数据包长度和窗口大小:

SET RECEIVE PACKET - LENGTH
SET WINDOW

也可以尝试使用 FAST 命令一次性启用所有性能选项。在串行连接中,如果可用,建议使用硬件流控制( SET FLOW RTS/CTS )而不是软件(XON/XOFF)流控制。

6. 总结

UNIX 系统在调制解调器控制和通信方面提供了多种方法和工具,包括系统自带的终端线路配置、相关命令,以及第三方通信软件。每种方法和工具都有其特点和适用场景,用户可以根据实际需求进行选择和配置。

在实际应用中,要根据具体任务的复杂程度和要求,合理运用这些方法和工具。对于简单的连接和传输任务,可以使用系统自带的命令;对于复杂的自动化任务,第三方通信软件如 C - Kermit 则能发挥更大的优势。同时,要注意配置文件备份、权限管理和性能优化等方面的问题,以确保系统的稳定运行和高效通信。

通过深入了解和掌握这些方法和工具,用户可以更好地利用 UNIX 系统的调制解调器功能,实现各种通信和文件传输需求。希望本文的介绍能为用户在 UNIX 系统中进行调制解调器控制和通信提供有益的参考。

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值