From: FINLEY@NKUVAX.BITNET (Kevin Finley)
Newsgroups: comp.os.vms
Subject: Re: tar for vms
Date: 11 Dec 92 17:45:17 GMT
Distribution: world
Organization: The Internet


  Greetings:



  TAR2VMS is the program (Version 2.3) to extract files from  a  Tar  format

  tape or file into a VMS system.  Major features:



  1.  It reads from either a tape or a file image of a tar tape



  2.  It transfers files as is, does NOT translate UNIX stream files to  the

      format that the VMS editor likes, but this is not a problem unless you

      intend to edit the files.  See below.



  3.  It can usually leave the tape positioned ready  to  read  another  Tar

      file  from  the tape.  NOTE:  there is a SET MAGTAPE option in VMS 4.x

      that will skip files to start reading in the middle of  a  tape.   The

      TAR2VMS program does not do any rewinds.



  4.  UNIX "linked" files are handled.



  5.  When file names are modified to suit VMS requirements,  a  message  is

      given on stdout.





  I will be glad to hear of your experiences with the code, since often when

  we get a Tar tape from a different system, we find something that I hadn't

  anticipated.  The program was developed by looking  at  DUMP  output  from

  various  tar  format  tapes  on  a  VMS  system,  so there are undoubtedly

  variations that I haven't seen.  ( I am not a UNIX expert..) We looked  at

  UNIX  manuals as well, but found some discrepancies in real tapes, so went

  with what seemed to work.



  I also have a Tar writer; ask for it if you need to transfer  files  to  a

  UNIX system from VMS.



  Sid Penstone,

  VLSI Group,

  Department of Electrical Engineering,

  Queen's University,

  Kingston, Ontario, Canada, K7L3N6

  phone (613) 545-2925



  BITNET:     PENSTONE@QUCDNEE1     (Preferred)

              PENSTONE@QUCDN        (If the other doesn't work)



  Introduction:



  The program TAR2VMS.C reads from a /foreign tape, or a file  which  is  an

  image  of  a Tar format tape, and extracts the files into a directory tree

  starting in the current default directory.  Directories  will  be  created

  automatically.



  For  example,  if  your   default   is   [JONES.MAIN],   then   the   file

  "electric/sub/test.c"         will         be         written         into

  [JONES.MAIN.ELECTRIC.SUB]TEST.C.



  For the simplest operation, just RUN it after defining the logical  "TAPE"

  to  be the the Tar source and doing a MOUNT/FOREIGN/BLOCK=10240/RECORD=512

  (if it is a tape); this does the extraction  automatically,  reporting  on

  stdout as it does.









  Converting the files:



  The extracted files will be written to your system as C stream files.  The

  VMS editor EDT will complain about the format, but EVE will not.



  To convert a text file to standard VMS format:

  (Thanks to Eric Gisin at U.  of Waterloo:)

  You can use the VMS CONVERT utility by  first  creating  a  xxxx.FDL  file

  containing:



  FILE

          ORGANIZATION            sequential

  RECORD

          BLOCK_SPAN              yes

          CARRIAGE_CONTROL        carriage_return

          FORMAT                  variable



  Then run  Convert  with  the  regular  DCL:   CONVERT/FDL=xxxx  input-file

  output-file



  Tar2vms Usage:



  To use TAR2VMS you must:



   o  Set up a foreign command by  including  the  following  line  in  your

      LOGIN.COM file:



           $ TAR2VMS == "$ Acs$Public:TAR2VMS.Exe"



   o  Define the logical variable "TAPE" to be the desired tape unit or  the

      file containing the Tar data.



   o  Mount the tape /FOREIGN/BLOCK=10240/RECORD=512



   o  Set the default directory below which the tree will be created  before

      calling   the   program.    Thus:    if   your  default  directory  is

      SYS$SYSDEVICE:[MYDIRE], the file "electric/dbase.c" will be written in

      SYS$DEVICE:[MYDIRE.ELECTRIC]DBASE.C



   o  Then run TAR2VMS:  (either by RUN or as a command:   TAR2VMS)  if  you

      use  RUN  ACS$PUBLIC:TAR2VMS,  the  operation  is  (extract,  verbose)

      otherwise:  'command' [options]

      where the options are:

           "t" (listing only)     Listing of files on tape

           "x" (extract)          Extract files from the tape

           "v" (verbose)          Report activity

           "w" (wait)             ...Not implemented



   o  to use the options, the program must be  executed  using  the  foreign

      command feature of VMS, by defining a command, TAR2VMS, as show above.



   o  Example:

      If the command is 'tar2vms', then:

           tar2vms t      will list the contents of the tar file

           tar2vms xv     will extract all of the files, reporting



  The listing reports the UNIX protection  (in  octal),  the  file  size  in

  bytes, the modification date on the tape, and the file name.









  ERRORS:



  Most probable causes:



      "Can't open input file" - likely forgot to define TAPE, or

                                mount the tape.



      "Error reading input"   - unexpected Tar format, or bad file.



      "Error writing output"  - directory access error



      "Creation Error..."     - illegal directory or file name





  Important assumptions for this version (2.3):



  The defaults are (no options):



   o  Extract all of the files, reporting as each file is created



   o  Read from a tape, mounted foreign, or a fixed record length  file,with

      block  size of 10240 bytes or less .  If larger block size, change the

      definition of SIZE.



   o  Stop on the special (blank header) block written by UNIX.  (Note, like

      UNIX  Tar,  it  does not move to the file mark at the end of the file.

      Answer "y" to the prompt to get  to  another  tar  file  on  the  same

      tape.)THIS MIGHT NOT WORK...



   o  All files are assumed to be UNIX stream and are just copied.  The  vms

      file-attribute  will  be  "stream".   This  may  have to be changed in

      certain cases with CONVERT, or by writing a little C program  to  read

      the file and rewrite it.



   o  When a UNIX linked file is encountered, there will be another file  on

      the tape that contains the actual data.  It may not be an earlier file

      that was the  original  file,  since  the  files  are  written  on  in

      alphabetical  order.  The program will create a file under the name of

      the linked file, but it will contain only a  text  messsage  reporting

      the name of the file that contains the data.



  This version converts the path names to VMS  format  before  creating  the

  files.  Some special cases:



  1.  File names with more than one period (".")  in  the  name  have  those

      after the first converted to underscores (e.g.  "mults.s.c" is written

      out under the name "mults.s_c"



  2.  It is assumed that all of the pathnames on the Tar tape have  complete

      directory info, with no device parts.



  3.  Commas and hyphens  in  file  or  directory  names  are  converted  to

      underscores.   If this causes any problems, you can modify the code in

      vms_cleanup().Any such translations are reported in "verbose" mode.



  4.  Files are created with the user's default protection.  The mode on the

      tape is ignored.









  5.  The dates of files extracted are the date of the extraction,  not  the

      date of the Tar version.



  6.  UNIX files that have no extension, and end in a letter will have a "."

      added  to  the name automatically.  This can cause some mysteries with

      large programs that look for other files with an exact string  search.

      Also, if the files are written out to UNIX as a TAR tape from VMS, the

      "." goes along with the file name.





  Known Bugs:





   o  Can't always read another file on the same  tape.   The  program  only

      works  correctly  when  the  tape  had  regular EOF marks on it, which

      apparently is not always true.



   o  Can't selectively extract files from  the  tape.   The  "wait"  option

      could be useful, but haven't got around to it..




Newsgroups: comp.os.vms