home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 1 / 1395 < prev    next >
Encoding:
Internet Message Format  |  1990-12-28  |  2.1 KB

  1. From: pvo@sapphire.OCE.ORST.EDU (Paul O'Neill)
  2. Newsgroups: alt.sources
  3. Subject: [comp.unix.questions] Re: Reading IBM Tape
  4. Message-ID: <1990May31.035426.21873@math.lsa.umich.edu>
  5. Date: 31 May 90 03:54:26 GMT
  6.  
  7. Archive-name: readEBCDICansi/31-May-90
  8. Original-posting-by: pvo@sapphire.OCE.ORST.EDU (Paul O'Neill)
  9. Original-subject: Re: Reading IBM Tape
  10. Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti)
  11.  
  12. [Reposted from comp.unix.questions.
  13. Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).]
  14.  
  15. In article <23453@adm.BRL.MIL> zellich@stl-07sima.army.mil ( Rich Zellich) writes:
  16. >If the problem is reading a standard-label EBCDIC tape, then .......
  17. >
  18. You might try this:
  19.  
  20. (tcopy the tape first and adjust the ibs block size accordingly)
  21.  
  22. #!/usr/local/bin/perl
  23. #
  24. #       readEBCDICansi
  25. #
  26. #       6 apr 90
  27. #       Paul V. O'Neill
  28. #    Coastal Imaging Lab
  29. #    Oregon State University
  30. #
  31. #       read an ansi-labeled tape coded in EBCDIC!
  32.  
  33.  
  34. while(1) {
  35.     open(HEADER, 'dd if=/dev/nrmt0 ibs=80 conv=ascii cbs=80|');
  36.     $name = '';                                 # undef for die test
  37.     while(<HEADER>) {                           # read the ansi header w/ dd
  38.         print $_;                               # verbosely
  39.         $name = $1 if /^HDR1(\w*)/;     # found file name (ignores ".ext")
  40.     }
  41.     close(HEADER);
  42.     print "$name\n\n";                          # more verbosity
  43.     die "$0: Looks like EOT $! $?\n" if $?;     # dd return error
  44.     $name || die "$0: No name found $! $?\n";   # dd ok, but no name!
  45.  
  46.     open(OUT, ">$name");                        # open the output disk file
  47.     open(DATA, 'dd if=/dev/nrmt0 ibs=3600 conv=ascii|');
  48.     while(<DATA>) {                             # read tape file w/ dd
  49.         s/\015//;                               # strip out infidel CR's
  50.         print OUT $_;                           # and write to disk file
  51.     }
  52.     close OUT;
  53.     close DATA;
  54.     system 'mt -f /dev/nrmt0 fsf 1';            # skip the trailer tape file
  55. }
  56.  
  57.  
  58. Paul O'Neill                 pvo@oce.orst.edu        DoD 000006
  59. Coastal Imaging Lab
  60. OSU--Oceanography
  61. Corvallis, OR  97331         503-737-3251
  62.