Pseudodevices and redirection
As we saw in working with files it is usually possible to give a pseudodevice name such as *SOURCE*
instead of a filename. This post will go over what pseudodevices are available and also how redirection of command input/output works.
Pseudodevices
The following pseudodevices come as standard on the D6.0 distribution:
*MSOURCE*
is the master source of input, either the keyboard for interactive sessions or the card reader for batch. It cannot be redefined.*MSINK*
is the master output destination, either the screen for interactive sessions or the printer for batch. It cannot be redefined either.*SOURCE*
is the current source of input, initially*MSOURCE
, and can be redefined.- Similarly
*SINK*
is the current output destination, initially*MSINK
, and can be redefined. *DUMMY*
is the empty device, similar to/dev/null/
on Unix.*PUNCH*
is the card punch device - on Hercules this is emulated by writing to a file. If output is sent to*PUNCH*
during an interactive session, a new batch job will be set up to do this.*PRINT*
is the print device. Again on Hercules this is emulated by writing to a file.- Output to
*BATCH*
creates a new batch job with the data sent used as the commands to execute. *IMPORT*
and*EXPORT*
were used for BITNET connections and are not available on Hercules.*TAPE1*
to*TAPE9*
are used as logical device names when mounting a tape on the emulated system.
You can also create your own pseudodevices using the MTS $MOUNT
and $CREATE
commands.
Redirection using $SOURCE
and $SINK
You can use the MTS commands $SOURCE
and $SINK
to change the default input and output from *MSOURCE*
and *MSINK*
. In the below example I redirect output to the temporary file -sinkfile
and then run $FILESTATUS
. The output of the command is stored there and not displayed on screen. Finally I run $SINK PREVIOUS
to restore the output to *MSINK*
.
# sink -sinkfile
# filestatus
# sink previous
# list -sinkfile
1 filestatus
2 ALPHA
3 BETA
4 sink previous
Logging input/output with $LOG
The MTS command $LOG
will create a copy of input/output.
# log -logfile
# filestatus alp?
ALPHA
# log off
Logging of *MSINK* on -LOGFILE terminated.
# copy -logfile
> $Log Output: REL., Job#=40, Host=MT, 22:16:47 Sun Jun 28/14
> #filestatus alpha
> ALPHA
> #log off
The $DISPLAY LOGSTATUS
command can be used to show what logging is currently in effect.
Logical I/O units
Logical I/O units provide a way for a program to access files without having to specify them in advance. For example, a program may read from logical I/O unit SCARDS
which you could define to be a file called ALPHA
using SCARDS=ALPHA
.
There is a common set of I/O units defined for each program, such as SCARDS
and also a free set of I/O units numbered 0-99. The common set of I/O units and their defaults are:
SCARDS
is used for input and defaults to*SOURCE*
.SPRINT
is used for printed output and defaults to*PRINT*
.SPUNCH
is used for output and defaults to*PUNCH*
.SERCOM
andGUSER
default to*MSOURCE*
and*MSINK*
.
The example below shows the *SORT
command being run with input coming from the file ALPHA
and output going to *SINK*
, ie the screen. The PAR=
part of the command line is the parameters for the sort rather than an I/O device; here CH,A
means sort by characters ascending,
# list alpha
1 Line B
2 Line C
3 Line A
# run *sort scards=alpha spunch=*sink* par=sort=ch,a
# Execution begins 22:41:56
Line A
Line B
Line C
Statistics: 3 input/ 0* intermediate files
# Execution terminated 22:41:56 T=0.012
Further information
See MTS Volume 1 or the online help topics such as Pseudodevices
and LOG
.