Hi again,

Sorry for the delayed answer.

Thank you for all your comments (Yes Joseph, I will try to enhance my basic
abilities - sorry for the bad code:-)

My thoughts on this project was to make a perl script which copy the content
of a tape to disk, no matter if it is tar archives, binary files, EBCDIC and
so on, much like the UNIX tcopy. But, I work on Linux and don't have the
tcopy available.

When you write multiple files to a tape it creates an physical "end of file
marker" at the end of each file. When some applications write to tape they
make an EOF between each file and then a double EOF at the end of the tape.

So, the idea was to stream out the data in a unaltered form to disk,
creating a new file each time perl finds a EOF marker.

I tried to use the binmode function, fx:

binmode STDOUT;
open BIN, "< $ARGV[0]";
open OUT, "> perltest.bin";
binmode BIN, ":raw:";
print OUT <BIN>;
close BIN;
close OUT;

That give the all the content on the tape into one file.

In conjunction with this I used the "read" function, but here I have to give
a block size - and since the block size varies it does not work well! Fx one
of the file types have a 3200 bit EBCDIC header followed by 400 byte binary
header and the rest of the file can have any byte size. This means that I
would have to chose 1 as block size to get everything out with "read", and
that is a time consuming task (please correct me if I am wrong).

I also looked at the "eof" function and tried to test the filehandle on this
but with no luck.

If you have any clues or suggestions I would really appreciate it.

Thanks again,
Jakob


-----Oprindelig meddelelse-----
Fra: David le Blanc [mailto:[EMAIL PROTECTED]
Sendt: 12. marts 2004 02:18
Til: R. Joseph Newton; [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Emne: RE: Read from tape device


> -----Original Message-----
> From: R. Joseph Newton [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, 10 March 2004 5:37 PM
> To: [EMAIL PROTECTED]
> Cc: [EMAIL PROTECTED]
> Subject: Re: Read from tape device
> 
> [EMAIL PROTECTED] wrote:
> 
> > Hi All,
> >
> > I am trying to read some data from af unix tape device. The 
> have several files with "end of file markers". Can I read 
> from tape devices at all?
> >
> > I tried "open" on the device and this one reads all files 
> on the tape into the first file and then hangs. Is it my code 
> (I know the first loop is not very good:-) or does perl not 
> recognise or honer the EOF marks?
> >
> > Thanks,
> > Jakob
> >
> > my $cnt = 0;
> > while (1 == 1) {
> >         open IN, "<", "/dev/nst0" || die "cant open ...\n";
> >         while (@out = <IN>) {
> 
> Why are you using an array?. That puts the read operator in 
> list context, so that it reads all lines of the file into the 
> @out array on the first round through the loop.
> 

Isn't this a perfect example of when you should be using
RECORD based I/O?

What is the tape block size?

> >
> >                 $cnt++;
> 
> Please use vowels.  They are neither poisonous nor explosive.
> 
> >
> >                 open OUT, ">", "$cnt.bin" || die "cant open out\n";
> >                 print OUT "@out\n";
> >                 close OUT;
> >         }
> > }
> > close IN;
> [snip]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>

Reply via email to