Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I've inherited a non-working Windows process of periodically writing a tar to tape. I can interact with the tape as follows, for example:
mt.exe eject tape0 mt.exe load tape0
But I haven't figured out how to read the tape. The process was calling GNU tar from a batch file, and giving an "invalid argument" error. I'm trying the following with Archive::tar's ptar, and getting similar errors:
perl ptar -tvf tape0 perl ptar -tvf \\.\tape0 perl ptar -tvf //./tape0
Any tips on ptar? Thanks!

Replies are listed 'Best First'.
Re: Archive::tar tape0
by jethro (Monsignor) on Jun 14, 2008 at 01:54 UTC
    I would suggest temporarily substituting gnu tar on that machine with a shell script that prints out its arguments

    That way you can find out with which arguments tar is called by this process.

Re: Archive::tar tape0
by starbolin (Hermit) on Jun 14, 2008 at 05:32 UTC

    Tar reads and writes to the tape device by default (compiled-in device) specifying  tar -tf tape0 on the command line attempts to extract the tar file "tape0" in the current directory to stdout. To see the archive contents from the tape:  tar -t. To extract from the tape onto disk:  tar -x. If tar doesn't see the tape for some reason then using the -f switch with the full device path  tar -tvf /dev/tape0 may work or it may not work depending on whether /dev/tape0 is a valid block device on your system. One problem is that you may have to set the correct blocksize to avoid an error. Try a blocksize of 20. If all else fails you may need to delve into the driver code for your particular tape drive to see what parameters it expects.


    s//----->\t/;$~="JAPH";s//\r<$~~/;{s|~$~-|-~$~|||s |-$~~|$~~-|||s,<$~~,<~$~,,s,~$~>,$~~>,, $|=1,select$,,$,,$,,1e-1;print;redo}
      Thanks apl, jethro, and starbolin. I still cannot communicate with the tape drive with Archive::Tar or GNU tar; but I installed cygwin and can do this:
      mount -s -f -b //./tape0 /dev/st0 tar -cf /dev/st0 *
      That's solution enough for me.
Re: Archive::tar tape0
by apl (Monsignor) on Jun 13, 2008 at 20:14 UTC
    Warning: I've never used this... ptar x apparently extracts files. If you want to incorporate this ability in another program, Archive::Tar has a read method.