Reading IBM Tape
Paul O'Neill
pvo at sapphire.OCE.ORST.EDU
Thu May 31 13:29:30 AEST 1990
In article <23453 at adm.BRL.MIL> zellich at 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 at oce.orst.edu DoD 000006
Coastal Imaging Lab
OSU--Oceanography
Corvallis, OR 97331 503-737-3251
More information about the Comp.unix.questions
mailing list