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:

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:

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.

Comments

comments powered by Disqus