Previous Page | Next Page

Using External Files and Devices

Processing Files on TAPE in UNIX Environments

Using the PIPE Device Type

You can use the PIPE device type together with the UNIX dd command to process a tape:

FILENAME fileref PIPE 'UNIX-commands';
UNIX-commands are the commands needed to process the tape.

The PIPE device type and the dd command enables you to use remote tape drives. However, using UNIX commands in your application means that the application will have to be modified if it is ported to a non-UNIX environment.

For example, the following DATA step writes an external file to tape:

x 'mt -t /dev/rmt/0mn rewind';
filename outtape pipe 'dd of=/dev/rmt/0mn 2> /dev/null';
data _null_;
   file outtape;
   put '1 one';
   put '2 two';
   put '3 three';
   put '4 four';
   put '5 five';

The following DATA step reads the file from tape:

x 'mt -t /dev/rmt/0mn rewind';
filename intape pipe 'dd if=/dev/rmt/0mn 2> /dev/null';
data numbers;
   infile intape pad;
   input digit word $8.;

If the tape drive that you want to access is a remote tape drive, you can access the remote tape drive by adding remsh computer-name or the following:

rsh computer-name

The above code is added to the X and FILENAME statements. For example, if the remote computer name is wizard , then you could read and write tape files on wizard by modifying the X and FILENAME statements as follows:

x 'remsh wizard mt -t /dev/rmt/0mn rewind';
filename intape pipe 'remsh wizard \
                dd if=/dev/rmt/0mn 2> /dev/null';

Working with External Files Created on the Mainframe

There are three main points to remember when dealing with tapes on UNIX that were created on a mainframe:

Previous Page | Next Page | Top of Page