VMS/TOPS20 tape readers

utzoo!decvax!ucbvax!unix-wizards utzoo!decvax!ucbvax!unix-wizards
Wed Oct 7 13:12:38 AEST 1981


>From eps at UCLA-Security Wed Oct  7 13:08:09 1981
Gee, I had the same problem about a year ago.  Here's a
quick and (very) dirty solution for transfering ASCII
TEXT files (for binary files, run them through uuencode
or similar):

Format of a VMS tape:

V H H H         E E   H H H          E E
O D D D e first O O e D D D e next e O O e e
L R R R o file  F F o R R R o file o F F o o
1 1 2 3 f       1 2 f 1 2 3 f      f 1 2 f f

Write the files to be transferred to tape using the DCL COPY
command.  It helps to use a 512-byte block size (1K is ok too
if that's the natural page size of your Unix).  The VMS default
is 2K.  If you try reading a tape whose blocksize is greater
than BUFSIZ (defined in <stdio.h>) with stdio, you lose.
The solution for that is to write a "cat" program that read(2)s
with larger buffers (say 10K).  Such a program might look like

[mtcat.c]
#include <stdio.h>
main() {
    register int i;
    char buf[512*20];
    while ((i=read(0,buf,sizeof buf))>0) write(1,buf,i);
    if (i<0) perror("read error");
}

Use  mtcat </dev/rmt0hn|magic-filter  instead of  magic-filter </dev/rmt0hn

On the Unix end of things, you do the following:

1) od -c </dev/rmt0hn
   This lets you read the name of the file from HDR1 and positions
   the tape in front of the file's data.  I actually don't use
   od -c, but it's good enough if you're really lazy.

2) convertansi </dev/rmt0hn >outfile
   convertansi is the magic-filter to convert counted variable-
   length records to newline-terminated records.

[convertansi.c]
#include <stdio.h>
#include <ctype.h>
main(argc,argv)
int argc;
char *argv[];
{
    register int c;
    if (argc!=1) {
	fprintf(stderr,"usage: %s <infile >outfile\n",*argv);
	exit(1);
    }
    while ((c=getchar())!=EOF) {
	if (isdigit(c)) {
	    register int n, i;
	    n=c-'0';
	    for (i=3;i>0;--i) { n*=10; n+=getchar()-'0'; }
	    for (n-=4;n>0;--n) putchar(getchar());
	    putchar('\n');
	}
    }
}

3) od -c </dev/rmt0hn
   If all went well, you should see the EOF labels.

4) od -c </dev/rmt0hn
   If you get nothing, you are at the end of the tape.
   Otherwise, you will see the HDR labels for the next
   file.  Repeat from step (2)

As for reading files from a DEC-20, I used the VAXTAP program
to write a VMS-compatible tape.  VAXTAP was written at DEC,
but I don't know if it's widely distributed (I got it from
LYONS at DEC-2136 since we didn't have it).

					Hope this helps,
					--Eric



More information about the Comp.unix.wizards mailing list