ttymon(1M) DG/UX R4.11MU05 ttymon(1M)
NAME
ttymon - monitor terminal ports
SYNOPSIS
/usr/lib/saf/ttymon
/usr/lib/saf/ttymon -g [ -d device ] [ -h ] [ -t timeout ] [-l
ttylabel ] [ -p prompt ] [ -m modules ] [ -T term-variable ]
where:
device is the pathname to a character-special device file
timeout is an integral number of seconds to wait for input
ttylabel is a name in the TTY settings file /etc/ttydefs
prompt is a string to be output to the device
modules is a comma-separated list of STREAMS modules
term-variable
is the value to which the TERM environment variable should
be set for the device.
DESCRIPTION
ttymon is a STREAMS-based TTY port monitor. It monitors device
ports, sets terminal modes, baud rates, and line disciplines for the
ports, and connects users or applications to services associated with
the ports. Normally, ttymon is configured to run under the Service
Access Controller, sac(1M), as part of the Service Access Facility
(SAF). It is managed using the sacadm(1M) command. Each instance of
ttymon can monitor multiple ports. The ports monitored by an
instance of ttymon are specified in the port monitor's administrative
file. The administrative file is managed using the pmadm(1M) and
ttyadm(1M) commands. (See the NOTES section for higher-level
management interfaces.)
When an instance of ttymon is invoked by the sac(1M) command, it
starts to monitor its ports. For each port, ttymon first initializes
the line disciplines, if they are specified, followed by the speed
and terminal settings. The values used for initialization are taken
from the appropriate entry in the TTY settings file. This file is
maintained by the sttydefs(1M) command. Default line disciplines on
ports are usually set up by the autopush(1M) command, interfacing
with the STREAMS Autopush Driver (SAD).
ttymon then writes the prompt and waits for user input. When valid
input is received, ttymon interprets the per-service configuration
script for the port, if one exists, creates a utmp(4) entry if
required, establishes the service environment, and then invokes the
service associated with the port. Valid input consists of a string
of at least one character (other than New Line), terminated by a New
Line. After the service terminates, ttymon cleans up the utmp(4)
entry, if one exists, and returns the port to its initial state.
If the "autobaud" feature is enabled for a port, ttymon will try to
determine the baud rate on the port automatically. Users must enter
a carriage return before ttymon can recognize the baud rate and print
the prompt. Currently, the baud rates that can be determined by this
feature are 300, 1200, 2400, 4800, and 9600 baud.
If a port is configured as a bidirectional port, ttymon will allow
users to connect to a service, and, if the port is free, will allow
uucico(1M), cu(1), or ct(1) to use it for dialing out. If a port is
bidirectional, ttymon will wait to read a character before it prints
a prompt.
If the "connect-on-carrier" flag (see ttyadm(1M)) is set for a port,
ttymon will immediately invoke the port's associated service when a
connection request is received. The prompt message will not be sent.
When a telnet or rlogin connection is established via a VTC/PTC,
ttymon will consider whether to allow auto-login, and whether to
carry the TERM variable forward from the remote host.
If a port is disabled, ttymon will not start any service on that
port. If a disabled message is specified, ttymon will send out the
message when a connection request is received. If ttymon is
disabled, all ports under that instance of ttymon will also be
disabled.
Service Invocation
The service ttymon invokes for a port is specified in the ttymon
administrative file. ttymon will scan the character string giving
the service to be invoked for this port, looking for a %d or a %%
two-character sequence. If %d is found, ttymon will modify the
service command string by replacing those two characters with the
full path name of this port (the device name). If %% is found, those
two characters will be replaced by a single % character.
When the service is invoked, file descriptors 0, 1, and 2 are opened
to the port device for reading and writing. The service is invoked
with the user ID, group ID, and current home directory set to that of
the user name under which the service was registered with ttymon.
Two environment variables, HOME and TTYPROMPT, are added to the
service's environment by ttymon. HOME is set to the home directory
of the user name under which the service is invoked. TTYPROMPT is
set to the prompt string configured for the service on the port.
This is provided so that a service invoked by ttymon has a means of
determining if a prompt was actually issued by ttymon and, if so,
what that prompt actually was.
See ttyadm(1M) for options that can be set for ports monitored by
ttymon under the Service Access Controller.
Configuration Variables
When run under the SAC, ttymon supports several configuration
variables.
After a service terminates, ttymon first consults CHILD_DIED_DELAY,
which specifies the number of seconds to leave the port idle.
If CHECK_IN_USE is set to 1, ttymon next tests whether any other
processes have the port open. This test is repeated every
RETRY_IN_USE_DELAY seconds until all such processes close the port or
terminate (or until ttymon gives up). If CHECK_IN_USE is set to 0,
ttymon does not enforce this requirement, and RETRY_IN_USE_DELAY has
no effect.
RETRY_DELAY has a more general effect. It specifies the number of
seconds to wait before trying again after an attempt to access a port
fails for any reason.
When a telnet or rlogin connection is established via a VTC/PTC,
ttymon first attempts to retrieve a TERM variable from the remote
host. After converting it to lowercase for telnet (but not for
rlogin), ttymon next consults TERM_TRANSLATE, which, if set, should
contain a comma-separated list of translation pairs. Unless the
result is an empty string, it will be used rather than any TERM
setting that may be defined in the port service. For example, the
following would translate abc to def, and would use the definition in
the port service rather than unknown (which is sent by some telnet
implementations when TERM is unset on the remote host):
assign TERM_TRANSLATE=unknown,,abc,def
These variables may be set in the per-port monitor configuration
script, which is managed using the sacadm(1M) command. By default,
ttymon behaves as if its configuration script contained the following
lines:
assign CHILD_DIED_DELAY=0
assign CHECK_IN_USE=1
assign RETRY_IN_USE_DELAY=2
assign RETRY_DELAY=2
Stand-Alone Operation
A special invocation of ttymon is provided that runs independently of
the SAC (i.e., does not depend on sac(1M) or its configuration
files). This independent "express" mode is the only invocation of
ttymon that accepts command line options and arguments. This form of
the command should be called only by applications that need to set
the correct baud rate and terminal settings on a port and then
connect to login(1) service, but that cannot be pre-configured under
the SAC.
Options are:
-g Enable the independent "express" mode of ttymon. This option
is required in order to use any of the other options below.
-d device
Attach ttymon to the port device, which must be the full path
name of a character-special device file. If this option is
not specified, the invoking process must connect file
descriptor 0 to a TTY port before starting ttymon.
-h Do not disconnect the line before initializing the terminal
settings. If this option is not set, ttymon will force a
hangup on the line by setting the speed to zero before setting
the speed to the default or specified speed.
-t timeout
Specify that ttymon should exit if no one types anything in
timeout seconds after the prompt is sent.
-l ttylabel
Look up the entry named ttylabel in the /etc/ttydefs file.
This definition tells ttymon at what speed to run initially,
and what the initial TTY settings are. The default speed is
9600 baud.
-p prompt
Print the prompt string prompt when the port is ready for
input. The default prompt is "login: ".
-m modules
When initializing the port, pop all modules on the port, and
then push modules in the order specified (leftmost first).
modules is a comma-separated list of pushable STREAMS modules.
Default modules on the ports are usually set up by the
autopush(1M) command, interfacing with the STREAMS Autopush
Driver (SAD).
-T term-variable
Set the TERM environment variable to term-variable for the
device.
EXAMPLES
/usr/lib/saf/ttymon -g -d /dev/console -m ldterm -l console
This example runs ttymon in express mode on the console device,
/dev/console. The basic STREAMS line discipline module ldterm will
be pushed onto the console stream, and the console entry in the TTY
definitions file will be referenced to set the line speed and
terminal settings.
FILES
/etc/ttydefs TTY settings file
SEE ALSO
ct(1), cu(1), login(1), admportservice(1M), admterminal(1M),
autopush(1M), pmadm(1M), sac(1M), sacadm(1M), sttydefs(1M),
sysadm(1M), ttyadm(1M), uucico(1M), utmp(4), Managing the DG/UX
System.
NOTES
If a port is monitored by more than one ttymon, it is possible for
the ttymons to send out prompt messages in such a way that they
compete for input.
For a high-level, user-friendly interface to ttymon and port
services, use the "Ports" menu of sysadm(1M) or xsysadm(1M). For an
intermediate-level, object-oriented interface, use the
admportmonitor(1M) and admportservice(1M) utilities.
Licensed material--property of copyright holder(s)