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*.
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 and GUSER 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.
Once how you’ve learnt how to work with files in MTS it’s easy to use the built in MTS commands - there are less than 50 commands and they follow the same basic syntax.
This post will give a quick tour of the commands available in MTS. I’ve grouped them by topic and provided a very brief summary for each.
As always, you can optionally start commands with $, commands can be abbreviated, eg FILESTATUS to FI, and there are some command synonyms shown with / below, such as HELP/EXPLAIN.
General commands
COMMENT - ignored line, can also use *
DISPLAY - show parameters and settings
HELP/EXPLAIN - interactive help system
MTS - return to MTS command mode from another program
SET - set MTS global options
SET and DISPLAY respectively set and show a large number of different settings such as printer settings, passwords, how MTS displays help etc.
File commands
COPY - copy lines to files
CREATE - create a new file
DESTROY - remove a file
DUPLICATE - create a duplicate of a file, making a new file if needed
EDIT - edit a file
EMPTY - remove contents of a file or set of files
FILEMENU - interactive selection of files
FILESTATUS - view information about files
LIST - display files
LOCK - lock a file
LOCKSTATUS - display status of locks on files
PERMIT - grant access to files
RENAME - rename a file or set of files
RENUMBER - renumber a line file
TRUNCATE - remove unused space at end of file
UNLOCK - unlock a file
A quick illustration of the difference between COPY and DUPLICATE:
# create x
File "X" has been created.
# copy *source* x
> Hello world
> Welcome to MTS
> Goodbye!
> $endfile
# list x
1 Hello world
2 Welcome to MTS
3 Goodbye!
# create y
File "Y" has been created.
# copy x(2,3) y
# list y
1 Welcome to MTS
2 Goodbye!
# duplicate x z
File "X" has been duplicated as "Z"; size=1 page; access=Unlim Owner,
None Others
# list z
1 Hello world
2 Welcome to MTS
3 Goodbye!
EMPTY effectively deletes a file and then recreates it with no contents. TRUNCATE will remove space allocated to the file but not used - handy for when disk usage was paid for but less so on an emulated system.
Sessions
LOG - log session to a file
SIGNOFF - log out of the system
SIGNON - log into the system
Run programs
RERUN - reissue the previous RUN command, optionally changing parameters
RUN - run a program
SINK - send output to a file/device
SOURCE - take input from a file/device
Devices and queues
CONTROL - operations on files and devices, eg rewind a tape
CANCEL - stop batch or print jobs
MOUNT - mount tapes
RELEASE - stop using a pseudodevice like tape
System information
SYSTEMSTATUS - show system status, eg tasks or queues
Utilities
CALC - desktop calculator
Programming
ALTER/MODIFY - change contents of a register or shared memory
DEBUG - load a program and enter debug command mode
DUMP - print out register and CPU information
IF - test a condition, usually for use in a batch file
LOAD - load a program into memory but don’t execute it yet
MAKE - keep interrelated files in an consistent state
RESTART/START - restart a program, eg after an error
SDS - transfer control to debug mode
UNLOAD - remove a previously loaded program from memory
Other commands of less use for Hercules users
ACCOUNTING - view resources used and charges
FSMESSAGE - full screen message/email system
FTP - file transfer protocol
MESSAGE - line driven email system
NET - create a network connection
Networking on MTS needed special hardware, so the messaging and network system commands will not be of much use.
Further information
There is online help for each command which you can access directly eg HELP CALC. Full documentation on how to use the commands and what command line parameters are available is available in MTS Volume 1.
In future posts I will go into more detail on some of the more complex or interesting commands.
Working with files in MTS can seem quite different compared to other systems. There are features missing that are considered as standard today - directories, automatic creation of new files - but there are also features in MTS that are more powerful than Unix or Windows.
For example, the single command
$copy A(2,10,2)+B(*l)@bkwd C
copies the even numbered lines from 2-10 from A together with all lines from B in reverse order and stores in C. These operators apply to the file, not the command, so can be used on any MTS command line where they make sense.
Types of files
Permanent files need to be created explicitly. Maximum name length is 12 characters and as in Unix a file extension is entirely optional. Permanent files are private to each user unless access is explicitly granted to another user. If access is granted you can use the notation user:file to refer to the file.
Temporary files must start with - and names must be 8 characters or less. These do not need to be explicitly created but are automatically destroyed by the system when you log out or a batch job that creates them finishes.
Public files must begin with a * and their names must be 16 characters or less. These are generally system wide programs or libraries.
It’s also possible to refer to a pseudodevice instead of a file. These start and end with * - an example was seen in the up and running guide, copy *source* file, which copies input from the keyboard to a file.
The MTS documentation refers to FDnames - this means either a filename or a pseudodevice name. (Update: as Jeff notes in his comment below, FDnames also include devices and other modifiers such as line number ranges.)
Line files
By default files in MTS are line orientated - an individual line can be accessed directly rather than having to read from the start of the file. Each line can be up to 32k long. Line numbers can be negative and can contain up to three digits after the decimal point; the range allowed is -2147483.648 to 2147483.647.
You can specify part of a file by using (start, end, increment) after the file name, where each component is optional. You can use *f to refer to the first line in the file and *l for the last line. Some examples:
A(5,10) - all lines between 5 and 10 inclusive from A
A(5) - all lines from 5 onwards from A
A(*f, 5) all lines from start of file to line 5 inclusive
A(1,10,2) - lines 1, 3, 5, 7 and 9 from A
File options
You can add extra options while processing files by using operators starting with @. Some useful options:
@uc converts the file to upper-case
@trim removes trailing spaces
@bkwd processes the file in reverse order
Concatenation
You can explicitly concatenate two or more files using the + operator, eg copy a+b c.
There is also an implicit concatenation similar to the way the C language handles #include preprocessor directives, but working on all types of file.
This operation depends on the contents of the file. If a file contains a line such as $continue with b then the contents of b are effectively inserted at that point and the rest of the current file is ignored. A line such as $continue with b return will include all of file b at that point and then return to processing the rest of the current file.
Further Reading
See the ‘Files & Devices’ chapter in MTS Volume 1 for a full description.
I will come back to the topic of pseudodevices in a future post, which will also cover how to do redirection of file input and output.
The 3270 terminal operates a little differently from command line interfaces you may be used to on Unix or Windows. This article will go over the basics of using the 3270 (via an emulator) and how the device is supported in MTS.
Line mode
One of the most important differences is that normally the terminal operates in line mode - the host system will not receive any input until you send the line by pressing Enter.
A very small number of programs on MTS support binary mode, where each key is processed as it is pressed - an example is the editor in visual mode. (Update: see Jeff Ogden’s comment below for a more precise description of how the terminal interacts with the operating system.)
Special keys
As well as the regular alphanumerical keys the 3270 has a number of special keys used by MTS. On an emulated terminal there is normally a way to bring up a keypad with these keys - above is the keypad on the x3270 emulator. Depending on the emulator there are also keyboard shortcuts, eg Alt-C invokes Clear on x3270.
PA1 sends an attention interrupt that will normally make a program stop what it is doing, similar to Ctrl-C on Unix/DOS.
PA2 sends an end of file or cancel signal, similar to Ctrl-D on Unix and Ctrl-Z on DOS.
Clear will refresh the screen. This is especially useful when you disconnect a terminal session then reconnect.
The PF keys act as soft function keys
Device Commands
You can send special device commands to the display driver. These can normally be entered at any time, not just at the # prompt. Device commands all start with a % and can be abbreviated like MTS commands. Note that device commands will not appear in the terminal history after you press Enter.
%? will display the current terminal settings with output similar to the below.
The output of %? will list the current function keys. You can redefine these with %PFn cmd, so for example if you wanted PF2 to display file information using the $filestatus command you could enter
%pf2 $filestatus
Note that you do not need to press Enter after using a function key.
Scrolling
The mode determines how the screen will display output when there is more than one screen of text. Available modes area:
%roll where the screen will scroll up slowly when the bottom of the page is reached. This is the default mode.
%line is similar to roll but the screen will be cleared, previous output moved up and further output starts from the middle.
%fast where the whole output is displayed quickly with no scrolling or pausing.
%page where a page of output is displayed at a time. To move to the next page you press the SysReq or Attn key - however I have not got those keys to work, at least on x3270; instead I redefined PF3 to act as the pause/continue key using %pf3 %pause.
You can adjust the rate of scrolling with %rate N where N is a number between 1 (slowest) and 9 (fastest), default being 5.
You can scroll the display backwards and forwards using %wb and %wf; these are conveniently bound to PF1 and PF4.
Other useful commands
%activity will display the current task’s status and resource utilisation.
%grab will start a second command session using the same terminal. You can then switch between the two sessions by using %flip.
%quit will force a disconnect - useful if your session has crashed.
%reset will return all device settings you have changed back to their defaults.
%timeout off will prevent your terminal from being logged out after 30 minutes of inactivity.