unx40.htm
来自「Unix Unleashed, Third Edition is written」· HTM 代码 · 共 1,873 行 · 第 1/5 页
HTM
1,873 行
<PRE>#pmadm -l -pttyserv -s s01
PMTAG PMTYPE SVCTAG FLGS ID PMSPECIFIC
ttyserv ttymon s01 d root /dev/term/01 —
/usr/bin/login - 9600 - Welcome to UNIX, Please Login: - #
#pmadm -l -pttyserv
PMTAG PMTYPE SVCTAG FLGS ID <PMSPECIFIC>
ttyyserv ttymon 00s u root /dev/term/00s
<BR>/usr/bin/login 2400 login: #
ttyserv ttymon 01s u uucp /dev/term/01s b
<BR>/usr/bin/login 9600 login: #</PRE>
<H5 ALIGN="CENTER">
<CENTER><A ID="I21" NAME="I21">
<FONT SIZE=3><B>Enabling, Disabling, and Removing a Port Service</B>
<BR></FONT></A></CENTER></H5>
<P>To enable, disable, or remove a port service, use pmadm -e, pmadm -d, or pmadm -r, respectively. Hence, to enable s01 port monitor, enter
<BR></P>
<PRE>#pmadm -pttyserv -s s01 -e</PRE>
<P>whereas to disable it, enter
<BR></P>
<PRE>#pmadm -pttyserv -s s01 -d</PRE>
<P>and to remove it, enter
<BR></P>
<PRE>#pmadm -pttyserv -s s01 -r</PRE>
<H3 ALIGN="CENTER">
<CENTER><A ID="I22" NAME="I22">
<FONT SIZE=4><B>The </B><B><I>ttymon</I></B><B> port monitor</B>
<BR></FONT></A></CENTER></H3>
<P>As its name implies, the ttymon port monitor is responsible for invoking and monitoring port services associated with your system's tty ports. When invoked, ttymon looks up its /etc/saf/<<I>pmtag</I>>/_pmtab file to determine: which port services
to invoke; which tty port associates with which service; how the port services are configured (for example, startup in an enabled state, what line speed to configure tty port to, and so on); and which application, or process, to invoke upon user request
(for example, login service, uucp, and so on).
<BR></P>
<P>ttymon replaces both getty and uugetty. Though getty and uugetty are still supported by SVR4 for backward compatibility reasons, system administrators are strongly recommended to use ttymon. This recommendation stems from the following comparison:
<BR></P>
<OL>
<LI>ttymon administration conforms with SAF's generic interface. This brings managing ttymon port monitors into line with management concepts applied to other port monitors, providing the benefit of convenience.
<BR>
<BR></LI>
<LI>By using SAF management commands, the administrator has the choice of managing ttymon port services collectively or selectively. When using getty, the administrator can manage only one port at a time.
<BR>
<BR></LI>
<LI>One invocation of the ttymon port monitor by sac can take care of multiple ttys, whereas getty/uugetty requires an entry per supported tty in the /etc/inittab file.
<BR>
<BR></LI>
<LI>As will be discussed later, ttymon comes with support of a new feature, namely the AUTOBAUD feature. This feature allows ttymon to automatically determine the line speed suitable to the connected terminal.
<BR>
<BR></LI>
<LI>ttymon can optionally be invoked directly by init, in "express" mode. This may be done by including an entry in the /etc/inittab file. As a matter of fact, if you examine the contents of the /etc/inittab file, you will notice the existence of
a similar entry taking care of the UNIX system console in express mode. The entry should look similar to the following:
<BR>
<BR>co:12345:respawn:/usr/lib/saf/ttymon -g -v -p "Console Login: "-d /dev/console -l console
<BR></LI></OL>
<P>Upon reading this entry, init starts a ttymon port monitor to take care of console login needs. This particular invocation of ttymon falls beyond sac's control.
<BR></P>
<H4 ALIGN="CENTER">
<CENTER><A ID="I23" NAME="I23">
<FONT SIZE=3><B>Special Device Files and the Terminal Line Settings Database</B>
<BR></FONT></A></CENTER></H4>
<P>Among the arguments that the system administrator must pass to pmadm to create a port service, two will be described: the device special filename corresponding to the tty serial interface undergoing configuration and a label identifying an entry in a
terminal line settings database.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I24" NAME="I24">
<FONT SIZE=3><B>Device Special Filenames under SAF</B>
<BR></FONT></A></CENTER></H5>
<P>Special filenames underwent some changes under SVR4. In earlier releases of UNIX, getty and uugetty referred to the special files in the /dev directory as tty##, where ## refers to the actual port number. With SAF under SVR4, tty port special files are
maintained in a subdirectory called /dev/term and the special files are named ## in that directory. com1 port on a 386 machine is now referred to as /dev/term/00, whereas under getty it is referred to as /dev/tty00. Due to the ongoing support to uugetty
and getty, both conventions are currently supported. It is the administrator's responsibility, however, to make sure that the right convention is applied with his or her preferred way of invoking a port service.
<BR></P>
<H5 ALIGN="CENTER">
<CENTER><A ID="I25" NAME="I25">
<FONT SIZE=3><B>The Terminal Line Settings Database</B>
<BR></FONT></A></CENTER></H5>
<P>As mentioned earlier, this database is the ttymon administrative file, which defines the line settings applying to the tty port being invoked. The database filename is /etc/ttydefs, whereas getty's is /etc/gettydefs. Both files remain supported by SVR4
and both are maintained using the /etc/sbin/sttydefs command. A good understanding of these databases helps you to provide the level of support that matches the users' terminal emulation need. In the following discussion, however, only /etc/ttydefs' file
data structure is examined and explained. The use of the sttydefs command to add, modify, or delete entries in the database also is described.
<BR></P>
<P>The discussion begins with a close look at the contents of the /etc/ttydefs file. To list its contents, enter
<BR></P>
<PRE>#/usr/sbin/sttydefs -l
19200: 19200 opost onlcr tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread : 19200 opost onlcr sane tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread ::9600
ttylabel: 19200
initial flags: 19200 opost onlcr tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread
final flags: 19200 opost onlcr sane tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread
autobaud: no
nextlabel: 9600
9600: 9600 opost onlcr tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread : 9600 opost onlcr sane tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread ::4800
ttylabel: 9600
initial flags: 9600 opost onlcr tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread
final flags: 9600 opost onlcr sane tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread
autobaud: no
nextlabel: 4800
4800: 4800 opost onlcr tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread : 4800 opost onlcr sane tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread ::2400
ttylabel: 4800
initial flags: 4800 opost onlcr tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread
final flags: 4800 opost onlcr sane tab3 ignpar ixon ixany parenb istrip echo echoe echok isig cs7 cread
autobaud: no
nextlabel: 2400
.
.
.</PRE>
<P>As you see, sttydefs formats the listing into a user-friendly format. If you want the actual data structure of the command, enter
<BR></P>
<PRE>#cat /etc/ttydefs
.
.
.
onlcr sane tab3 ignpar istrip ixon ixany echo echoe echok isig cs8 cread ::console5
console5: 19200 opost onlcr tab3 ignpar istrip ixon ixany echo echoe echok isig cs8 cread : 19200 opost onlcr sane tab3 ignpar istrip ixon ixany echo echoe echok isig cs8 cread ::console
4800H: 4800 : 4800 ixany parenb sane tab3 hupcl ::9600H
9600H: 9600 : 9600 ixany parenb sane tab3 hupcl ::19200H
19200H: 19200 : 19200 ixany parenb sane tab3 hupcl ::2400H
2400H: 2400 : 2400 ixany parenb sane tab3 hupcl ::1200H
1200H: 1200 : 1200 ixany parenb sane tab3 hupcl ::300H
300H: 300 : 300 ixany parenb sane tab3 hupcl ::4800H
19200NP: 19200 opost onlcr tab3 ignpar ixon ixany istrip echo echoe echok isig cs8 cread : 19200
.
.</PRE>
<P>The following is a description of each field:
<BR></P>
<PRE>
<BR><I>Label</I>: It is unique and is used in identifying the record. You will be passing this label to ttymon, using pmadm, when creating the port service. Every time ttymon attempts invoking the port service, it searches for that label in the ttydefs
file.
<BR><I>Initial flags</I>: This field describes the initial terminal line settings. They allow users to provide login information upon initial contact.
<BR><I>Final flags</I>: They define the terminal line settings after a connection request is detected, and right before the associated port service is invoked.
<BR><I>Autobaud</I>: This field can contain either A or null. By including A in this field, you are prompting ttymon to automatically determine the line speed upon receiving a carriage return from the user's terminal.
<BR><I>Next label</I>: This field includes the label of the next record to fetch should the line settings specified in the current label fail to meet the user's terminal needs. ttymon recognizes the failure upon receiving a BREAK sent by the user. This
technique allows ttymon to fall back on any number of alternate configurations in search of the desired line speed. Records linked together in this fashion are said to form a hunt sequence, with the last one normally linked to the first record. The sample
partial listing shown previously includes a hunt sequence that starts with label 4800H and ends with 300H.</PRE>
<P>An example record in ttydefs follows, along with an explanation of its field contents.
<BR></P>
<PRE>9600NP: 9600 tab3 ignpar ixon ixany echo echoe cs8 : 9600 sane tab3 ignpar ixon ixany echo echoe cs8::4800NP</PRE>
<P>This record is labelled 9600NP. Both the initial and final flags set the port to 9600 bps, no parity (ignpar), enable XON/OFF flow control(ixon), any character should restart output (ixany), echo back every character typed (echo), echo erase character
(echoe), and to set the character size to 8 bits. The autobaud field is null, which means that no autobaud support is required. The last field points to the next record labelled 4800N.
<BR></P>
<P>To find more about the valid initial and final flag settings, consult your vendor's manuals, or simply enter "man stty" on the command line.
<BR></P>
<P>What if you don't find what you want in ttydefs? As noted earlier, SVR4 provides you with the /etc/sbin/sttydefs command to make changes to the /etc/ttydefs database. Among the changes you are allowed to make is adding the record of your liking. The
command syntax to do that follows:
<BR></P>
<PRE>#sttydefs -a<ttylabel> [-b] [-n<nextlabel>] [-i<initialflags>]\
[-f <finalflags>]</PRE>
<P>in which
<BR></P>
<PRE>
<BR>-a <<I>ttylabel</I>> adds an entry to ttydefs with label specified (first field)
<BR>-i <initialflags> specifies initial speed among other line settings (second field)
<BR>-f <finalflags> specifies final line settings (third field)
<BR>-b enables autobaud (fourth field in which case A will be included in this field)
<BR>-n describes the next record's label</PRE>
<P>For example, the sttydefs that follows adds a new record, labelled 4800, with initial flags set to support 4800 bps line speed:
<BR></P>
<PRE>#sttydefs -a4800 -i"4800 hupcl tab3 erase ^b" \
-f"4800 sane ixany tab3 erase ^h echoe" -n2400np</PRE>
<P>To remove an entry, simply enter sttydefs -r <<I>ttylabel</I>>.
<BR></P>
<P>For example: to delete the 4800 label, enter
<BR></P>
<PRE>#sttydefs -r 4800</PRE>
<HR ALIGN=CENTER>
<NOTE>
<IMG SRC="caution.gif" WIDTH = 37 HEIGHT = 35><B>CAUTION:</B> A record that you delete may belong to a hunt sequence, in which case it is your responsibility to restore integrity to the affected sequence.
<BR></NOTE>
<HR ALIGN=CENTER>
<H4 ALIGN="CENTER">
<CENTER><A ID="I26" NAME="I26">
<FONT SIZE=3><B>The </B><B><I>ttymon</I></B><B> Port Monitor Administrative Command </B><B><I>ttyadm</I></B>
<BR></FONT></A></CENTER></H4>
<P>ttyadm is ttymon's administrative command. Its prime function is to pass information to both sacadm and pmadm in the formats they require. The following are the ttyadm options:
<BR></P>
<PRE>
<BR>-V specifies the version of ttymon
<BR>-d device specifies the /dev/term/## tty with which the port service will be associated
<BR>-b if included, will configure the port service for bidirectional flow of data
<BR>-r <<I>count</I>> specifies the number of times ttymon should try to start the service before a failure is declared
<BR>-p "prompt" is the string used to prompt users when a port service request is detected.
<BR>-i "message" is the message to be displayed if the port is in a disabled state
<BR>-t <<I>timeout</I>> is the number of seconds that ttymon must wait for input data before closing the port
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?