#!/usr/bin/tclsh
#
# This utility lists the contents of the tape on /dev/st0. If you really
# want to dump its output to a file, use shell redirects
# (i.e. $ tape-contents > tape.log)
#####

exec mt -f /dev/st0 rewind

if [catch {set filename [exec tar -tf /dev/nst0]} result] {
puts ""
puts "The tape is probably blank. Here's what tar had to say about it:"
puts ""
puts stderr $result
puts ""
exit 1
}

set i 0

while {$filename != ""} {

puts ""
puts $i
puts $filename
puts "--------------------"
puts ""
exec mt -f /dev/nst0 fsf 1
set filename [exec tar -tf /dev/nst0]
incr i

}