[comp.unix.wizards] reading an "IBM tape" on UNIX

tamir@oahu.cs.ucla.edu (04/30/89)

I have received a tape that was written on an IBM mainframe
running some standard IBM OS (MVS/CMS ?).
Below are the IBM scripts used to read the tape
and to generate the tape.  I am trying to figure out
if there is a way to read this tape on UNIX.
The first step is to determine what this format is *called*.
For example, if this is an
   ANSI standard labeled tape
or
   CMS "tapedump" tape
there are some utilities to read it on UNIX.
If anybody can identify the "type" of the tape, please
let me know.

			   Yuval Tamir

Internet: tamir@cs.ucla.edu
    UUCP: ...!{uunet,ucbvax,rutgers}!cs.ucla.edu!tamir
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EXEC file for reading the tape
--------------------------------------------------------------------
trace off
'SET CMSTYPE HT'
'SET LDRTBLS 18'
'ACCESS 319 P'
'GLOBAL LOADLIB VFLODLIB'
'SET CMSTYPE RT'
 
execio 0 cp '(STRING SET PF1 IMMED HELP'
execio 0 cp '(STRING SET PF2 IMMED FILEL'
execio 0 cp '(STRING SET PF3 RETRIEVE'
execio 0 cp '(STRING SET PF4 FILEL'
/* execio 0 cp '(STRING SET PF5 IMMED FILEL * * D' */
execio 0 cp '(STRING SET PF12 IMMED CLRSCRN'
execio 0 cp '(STRING SET PF9 IMMED DISC'
 
execio 0 cp '(STRING SCREEN CPOUT YELLOW'
execio 0 cp '(STRING SCREEN VMOUT RED'
execio 0 cp '(STRING SCREEN INAREA RED UND'
execio 0 cp '(STRING SCREEN CPOUT YELLOW NONE'
execio 0 cp '(STRING SCREEN VMOUT TURQ NONE'
execio 0 cp '(STRING SCREEN INREDISP PINK UND'
 
exit

---------------------------------------------------------------------

EXEC file for generating the tape
--------------------------------------------------------------------

/*================================================================*/
/* "TAPECOPY" moves files from the tape ACMB to a temporary       */
/*  minidisk, or reads the copied files from that disk back to    */
/*  tape.  To run this exec, you must first do the following two  */
/*  things:  1) have the tape drive allocated as device 181,  the */
/*  operator must do this, so enter the command:                  */
/*      MSG OPERATOR PLEASE ATTACH 580 TO ME AS 181               */
/*  and 2) you must have defined and formatted a temporary disk   */
/*  (this exec assumes it is disk "F") with the commands:         */
/*     DEFINE TFB-512 AS 199 (BLK 60000                           */
/*     FORMAT 199 F (B 4096                                       */
/*                                                                */
/*  To copy the files from tape to tape, you must execute this    */
/*  exec twice,  first with the input tape mounted, next with     */
/*  the output (blank) tape mounted on the disk drive.  (Again,   */
/*  use the "MSG OPERATOR message text"  command to have the      */
/*  appropriate tape mounted.)  If you have the temporary disk    */
/*  accessed as disk "F", then simply do the following:           */
/*     1)  have the original (ACMB) tape mounted on the drive    */
/*     2)  enter: "TAPECOPY R"  -- to read the tape to disk       */
/*     3)  have the copy (output) tape mounted on the drive       */
/*     4)  enter: "TAPECOPY W"  -- to write the files to tape     */
/*  for clean-up:                                                 */
/*     5)  enter: "RELEASE F (DET"  -- release the temp disk      */
/*                                                                */
/*  Notes:                                                        */
/*     --  If your temp disk has a file mode other than "F",      */
/*         you may specify that file mode letter after the        */
/*         R or W in the TAPECOPY command; so steps 2 and 4 above */
/*         become:   TAPECOPY R fm                                */
/*                   TAPECOPY W fm                                */
/*         where "fm" is the actual file mode of the temp disk    */
/*                                                                */
/*     --  if you are concerned that these files be erased from   */
/*         the temporary disk space, re-enter the FORMAT command  */
/*         (as above) before RELEASing the temp disk;  this will  */
/*         wipe the disk space clean.                             */
/*                                                                */
/*                                                --  BGM 4/89    */
/*================================================================*/
 
signal on error
parse upper arg rw fm
 
do while (rw /= "R") & (rw /= "W") & (rw /= "Q")
   say " "
   say " Please enter one of the following:"
   say "    R -- to Read files from tape to disk"
   say "    W -- to Write files from disk back to tape"
   say "    Q -- to Quit  (and do nothing)"
   say " "
   say " Your choice (R, W, Q)?"
   pull rw
end
 
if rw = "Q" then exit
 
fn = "FILE"
ft = "TAPEFIL"
if fm = "" then fm = "F"
 
if rw = "R" then do
   ddone = "INDD"
   ddtwo = "OUTDD"
   end
else do
   ddone = "OUTDD"
   ddtwo = "INDD"
   end
 
"TAPE REW (TAP1 9TRACK DEN 6250"
 
"FILEDEF " ddone " TAP1 (LRECL 3 BLOCK 3519 RECFM FB"
 
do i = 1 to 7
   fno = fn || i
   "FILEDEF " ddtwo " DISK" fno ft fm "(LRECL 3 BLOCK 3519 RECFM FB"
   "MOVEFILE INDD OUTDD"
end
 
"TAPE REW"
 
exit
 
ERROR:
   say " "
   say " --------------------------------------------------------"
   say " An error has been detected while running TAPECOPY...    "
   say " "
   say " TAPECOPY terminating...."
   say " "
exit

-------------------- end file 2 --------------------------------

larry@macom1.UUCP (Larry Taborek) (05/04/89)

From article <23398@shemp.CS.UCLA.EDU>, by tamir@oahu.cs.ucla.edu:
> I have received a tape that was written on an IBM mainframe

[later]

> if there is a way to read this tape on UNIX.

[other stuff]

> /*     DEFINE TFB-512 AS 199 (BLK 60000                           */
> /*     FORMAT 199 F (B 4096                                       */

[lots of other stuff]

I have read successfully Mag tapes created off an IBM mainframe.
I use the dd command to read them.  You will probably have to
play around with this some, varying the parameters but try 
something like this:

dd if=/dev/rmt0 of=stuff0 conv=swab cbs=512

where rmt0 is the device driver for the mag tape device that you
are reading from and stuff0 is the file you are going to put the
results into.  You may need to change the cbs block size, or even
specify ibs (input block size) and obs (output block size).
Also, as this is an IBM tape, it may be written in ebcdic, so a
conv=ascii,swab may be needed.  Some machines treat bytes
differently then others.  When done running the command, if the
file stuff0 has every set of characters reversed (like the word
"spelling" spelled "sepllnig" then the conv=swab needs to be put
in.  Also some tapes are created with a header file, to get at
the next file, use the skip command.  All of this information is
described more fully in the manual page on dd.  

PS  Make sure you know what bpi the mag tape was written at, as
you will have to have the same bpi when reading it.




-- 
Larry Taborek	..!uunet!grebyn!macom1!larry	Centel Federal Systems
		larry@macom1.UUCP		11400 Commerce Park Drive
						Reston, VA 22091-1506
						703-758-7000

heilpern@ibd.BRL.MIL (Mark A. Heilpern ) (05/05/89)

In article <4847@macom1.UUCP> larry@macom1.UUCP (Larry Taborek) writes:
>From article <23398@shemp.CS.UCLA.EDU>, by tamir@oahu.cs.ucla.edu:
>> I have received a tape that was written on an IBM mainframe
>

>
>> if there is a way to read this tape on UNIX.
>
>
>> /*     DEFINE TFB-512 AS 199 (BLK 60000                           */
>> /*     FORMAT 199 F (B 4096                                       */
>

>I have read successfully Mag tapes created off an IBM mainframe.
>I use the dd command to read them.  You will probably have to
>play around with this some, varying the parameters but try 
>something like this:
>
>dd if=/dev/rmt0 of=stuff0 conv=swab cbs=512
>
>where rmt0 is the device driver for the mag tape device that you
>are reading from and stuff0 is the file you are going to put the
[lots deleted]

An easier method, if you are unfamiliar with the use of dd, is to
use the public domain program 'ansir', ansi-read.
I believe source for this exists on uunet.uu.net.
It can read files in a variety of different formats, including both
ascii, ebcdic, and binary, in the format of quite a few machines.
One bug in it I've found however: While trying to read files in
DEC format (from the rsx-11 operating system), 'ansir' was unable
to retrieve the file-name information. I later found out 'ansir'
had placed 14 extra bytes at the head of each file-- the name, user/group
codes, etc, in a compressed manner. It was rather difficult writing
the (basically simple) program to decode the name from this.
The difficulty was in a lack of information.

	--M.