[comp.unix.sysv386] portable `rewind' for tape devices

ires@kaspar.UUCP (Bruce R. Larson) (11/29/90)

I've been looking for a portable `rewind' to use in shell scripts,
and I may have found (or more likely, reinvented) the perfect solution.
I am posting this because it answers the rewind question raised in FAQ #5.

Here are a couple of Bourne shell functions to
i)  rewind the tape device, and
ii) advance to the next archive on the tape.


TAPE=dev/tape
NTAPE=/dev/ntape

rewind_tape(){
	dd if=$TAPE of=/dev/null count=0 2>/dev/null
}

advance_tape(){
	dd if=$NTAPE of=/dev/null count=0 2>/dev/null
}


It works for me!

Bruce

Bruce R. Larson				| The drug problem in the US is so
Integral Resources, Milton MA		|  vast that we need to recognize that
Internet: ires.com!blarson@cs.umb.edu	|   it is primarily a social problem,
Uucp:     ..!cs.umb.edu!ires.com!blarson|    not a criminal problem.
-- 

tneff@bfmny0.BFM.COM (Tom Neff) (11/30/90)

That's overkill.

To rewind:

	:</dev/tape

To advance:

	:</dev/ntape

but keep in mind that the specific device names vary according to
vendor.  (I.e. here it's /dev/rmt/c0s0 and /dev/rmt/c0s0n.)

ires@kaspar.UUCP (Bruce R. Larson) (12/01/90)

In article <16081@bfmny0.BFM.COM>, tneff@bfmny0.BFM.COM (Tom Neff) writes:
>
> To rewind:
>
> 	:</dev/tape
> 
> To advance:
> 
> 	:</dev/ntape
> 
> but keep in mind that the specific device names vary according to
> vendor.  (I.e. here it's /dev/rmt/c0s0 and /dev/rmt/c0s0n.)
>
Not only was my rewind overkill, but it had a problem with SCSI tape
drives.  Your's is much nicer.

Thanks for sharing it.

Bruce

Bruce R. Larson				| The drug problem in the US is so
Integral Resources, Milton MA		|  vast that we need to recognize that
Internet: ires.com!blarson@cs.umb.edu	|   it is primarily a social problem,
Uucp:     ..!cs.umb.edu!ires.com!blarson|    not a criminal problem.


-- 
Bruce R. Larson				| The drug problem in the US is so
Integral Resources, Milton MA		|  vast that we need to recognize that
Internet: ires.com!blarson@cs.umb.edu	|   it is primarily a social problem,
Uucp:     ..!cs.umb.edu!ires.com!blarson|    not a criminal problem.

richard@pegasus.com (Richard Foulk) (12/05/90)

>
>To rewind:
>
>	:</dev/tape
>

Or, to be portable between shells:

	echo < /dev/tape

root@ninja.dell.com (Randy Davis) (12/06/90)

In article <1990Dec5.114754.229@pegasus.com> richard@pegasus.com (Richard Foulk) writes:
|(someone else wrote):
|>To rewind:
|>	:</dev/tape
|Or, to be portable between shells:
|	echo < /dev/tape

  Or, how about just "< /dev/tape" - works just as well and should be just
as portable...

Randy Davis					UUCP: rjd@ninja.dell.com

--