Operating System - HP-UX
1834756 Members
2888 Online
110070 Solutions
New Discussion

Detecting DAT drive tapes

 
SOLVED
Go to solution
Edward McCouch
Frequent Advisor

Detecting DAT drive tapes

I need to write a script that will be activated by a cronjob to begin a make_recovery tape. Does anyone know what commands are used to figure out if there is a tape in a drive? I'm not sure where to start.
6 REPLIES 6
Dietmar Konermann
Honored Contributor

Re: Detecting DAT drive tapes

I usually use the diskinfo command. It sends also an SIOC_CAPACITY to the drive... which fails if no medium is inserted (no such device or address).

Best regards...
Dietmar.
"Logic is the beginning of wisdom; not the end." -- Spock (Star Trek VI: The Undiscovered Country)
Pete Randall
Outstanding Contributor
Solution

Re: Detecting DAT drive tapes

You can use the "mt status" command. Here's the result from an empty drive:

yukon(137)root# mt status
Drive: HP C1537A
Format:
Status: [0]
File: 0
Block: 0


And here's the result with a tape present:

yukon(138)root# mt status
Drive: HP C1537A
Format: DDS-1 format
Status: [45111300] BOT write-protected online compression immediate-report-mode

File: 0
Block: 0


Pete

Pete
Steven E. Protter
Exalted Contributor

Re: Detecting DAT drive tapes

istape=`ioscan -fnC tape | wc -l`

if [ istape gt 0 ]
echo "I found a tape drive"
else
echo "I didn't find a tape drive"
exit 1
fi

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Michael Steele_2
Honored Contributor

Re: Detecting DAT drive tapes

I've always used the mt command in my auto make_tape_recovery scripts and then checked its status.

mt -t /dev/rmt/0m rew
if [ $? !0 ]
then
echo alert | mailx -s ...etc.
fi
Support Fatherhood - Stop Family Law
Dario_1
Trusted Contributor

Re: Detecting DAT drive tapes

Edward McCouch
Frequent Advisor

Re: Detecting DAT drive tapes

Thank you all for responding. I was able to use the mt command to do what I wanted.