pvo@sapphire.OCE.ORST.EDU (Paul O'Neill) (05/31/90)
Archive-name: readEBCDICansi/31-May-90 Original-posting-by: pvo@sapphire.OCE.ORST.EDU (Paul O'Neill) Original-subject: Re: Reading IBM Tape Reposted-by: emv@math.lsa.umich.edu (Edward Vielmetti) [Reposted from comp.unix.questions. Comments on this service to emv@math.lsa.umich.edu (Edward Vielmetti).] In article <23453@adm.BRL.MIL> zellich@stl-07sima.army.mil ( Rich Zellich) writes: >If the problem is reading a standard-label EBCDIC tape, then ....... > You might try this: (tcopy the tape first and adjust the ibs block size accordingly) #!/usr/local/bin/perl # # readEBCDICansi # # 6 apr 90 # Paul V. O'Neill # Coastal Imaging Lab # Oregon State University # # read an ansi-labeled tape coded in EBCDIC! while(1) { open(HEADER, 'dd if=/dev/nrmt0 ibs=80 conv=ascii cbs=80|'); $name = ''; # undef for die test while(<HEADER>) { # read the ansi header w/ dd print $_; # verbosely $name = $1 if /^HDR1(\w*)/; # found file name (ignores ".ext") } close(HEADER); print "$name\n\n"; # more verbosity die "$0: Looks like EOT $! $?\n" if $?; # dd return error $name || die "$0: No name found $! $?\n"; # dd ok, but no name! open(OUT, ">$name"); # open the output disk file open(DATA, 'dd if=/dev/nrmt0 ibs=3600 conv=ascii|'); while(<DATA>) { # read tape file w/ dd s/\015//; # strip out infidel CR's print OUT $_; # and write to disk file } close OUT; close DATA; system 'mt -f /dev/nrmt0 fsf 1'; # skip the trailer tape file } Paul O'Neill pvo@oce.orst.edu DoD 000006 Coastal Imaging Lab OSU--Oceanography Corvallis, OR 97331 503-737-3251