Databases
cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to know if a tape is present in the drive or not?

SOLVED
Go to solution
Raghavendra R Gamoji
Occasional Visitor

What is the best way to know if a tape is present in the drive or not?

Hello folks,

I know my question is very basic. But I want to know the simplest command/way to check it.

TIA(tnx in adv),
Raghu.
Unix is not for those who dont luv it!
8 REPLIES
Vincent Stedema
Esteemed Contributor
Solution

Re: What is the best way to know if a tape is present in the drive or not?

Hi,

You can try:

mt -t status /dev/rmt/0mn

It prints status information on the tape if there is one present in the drive.

Vincent
Steven Sim Kok Leong
Honored Contributor

Re: What is the best way to know if a tape is present in the drive or not?

Hi,

# mt -t /dev/rmt/0m status

Hope this helps. Regards.

Steven Sim Kok Leong
Email: steven@beepz.com. Homepage: https://www.beepz.com
Steven Sim Kok Leong
Honored Contributor

Re: What is the best way to know if a tape is present in the drive or not?

Hi,

Apparently, only Linux supports the status option. You can try any of the other valid options such as rew and offl. Catch the error code to identify whether a tape is inside the drive.

# mt -t /dev/rmt/0m rew
# echo $?

# mt -t /dev/rmt/0m offl
# echo $?

Hope this helps. Regards.

Steven Sim Kok Leong
Email: steven@beepz.com. Homepage: https://www.beepz.com
Vincent Stedema
Esteemed Contributor

Re: What is the best way to know if a tape is present in the drive or not?

Oops, I got the syntax wrong...

Steven's right: it's "mt -t status". If you're running hp-ux 11.00, the syntax can be either "mt -f status" or "mt -t status".

Vincent
Raghavendra R Gamoji
Occasional Visitor

Re: What is the best way to know if a tape is present in the drive or not?

Hello Vincent/Steven
Thanks a lot ;)
Raghu
Unix is not for those who dont luv it!
Roberto Martinez_2
Frequent Advisor

Re: What is the best way to know if a tape is present in the drive or not?

I think the best way to know if a tape is present in the drive or not is to try to insert another tape. If you can't, the drive wasn't empty.
Bill Hassell
Honored Contributor

Re: What is the best way to know if a tape is present in the drive or not?

The status option was added to mt for 11.0, but not for 10.20 or earlier. The rewind offline (mt -t xxx offl) will pop out the tape. I am assuming that you want to detect the tape's presence for a backuo script, so don't use offline or the drive will always be empty.


Bill Hassell, sysadmin
Tom Danzig
Honored Contributor

Re: What is the best way to know if a tape is present in the drive or not?

If you do:

mt eof

and check for exit status 0, this will not only tell you that there is a tape in the drive but also that it is not write protected.