How to check about the presence of a tape in the tape drive

How to check about the presence of a tape in the tape drive

Post by Steve » Wed, 03 Nov 1999 04:00:00



rc=`tctl -f /dev/rmt? rewind`

If there is a tape in the drive, nothing will get returned to rc.

Steve T


> I am new to IBM machines. We have IBM RS6000, running AIX 4.3.2.

> I have a script which automatically takes backup of the database at
> night. However I need a mechanism to find whether any tape is present in
> the tape drive. If it isn't, then I can bail out rather than invoking
> the backup program which assumes the tape to be present in the drive.
> This will be very useful when someone forgets to put a tape in the
> drive.

> Question: Is there a command in AIX which I can call from my shell
> script to find out whether the tape drive has any tape or not?

> Please email me the answer as I don't visit this ng.

> TIA.

> Ravi.

> Sent via Deja.com http://www.deja.com/
> Before you buy.

 
 
 

How to check about the presence of a tape in the tape drive

Post by Christopher J. Matter » Wed, 03 Nov 1999 04:00:00


Not quite.  The error message you get back goes to _stderr_, which
your example does not redirect to the variable.  You need this
(I also replaced the backticks with the preferred $() ):

rc=$(tctl -f /dev/rmt? rewind 2>&1)

Of course, you also get a return code from tctl, so you can
also do stuff like this:

if (tctl -f /dev/rmt? rewind)
then
  do stuff with the tape
else
  we got no tape here!
fi

                   Chris Mattern


> rc=`tctl -f /dev/rmt? rewind`
> If there is a tape in the drive, nothing will get returned to rc.
> Steve T

>> I am new to IBM machines. We have IBM RS6000, running AIX 4.3.2.

>> I have a script which automatically takes backup of the database at
>> night. However I need a mechanism to find whether any tape is present in
>> the tape drive. If it isn't, then I can bail out rather than invoking
>> the backup program which assumes the tape to be present in the drive.
>> This will be very useful when someone forgets to put a tape in the
>> drive.

>> Question: Is there a command in AIX which I can call from my shell
>> script to find out whether the tape drive has any tape or not?

>> Please email me the answer as I don't visit this ng.

>> TIA.

>> Ravi.

>> Sent via Deja.com http://www.deja.com/
>> Before you buy.


 
 
 

How to check about the presence of a tape in the tape drive

Post by Steve » Thu, 04 Nov 1999 04:00:00


Thanks for the correction, wasn't paying attention to what I was typing. Must
learn to proof read :)

Steve T


> Not quite.  The error message you get back goes to _stderr_, which
> your example does not redirect to the variable.  You need this
> (I also replaced the backticks with the preferred $() ):

> rc=$(tctl -f /dev/rmt? rewind 2>&1)

> Of course, you also get a return code from tctl, so you can
> also do stuff like this:

> if (tctl -f /dev/rmt? rewind)
> then
>   do stuff with the tape
> else
>   we got no tape here!
> fi

>                    Chris Mattern


> > rc=`tctl -f /dev/rmt? rewind`

> > If there is a tape in the drive, nothing will get returned to rc.

> > Steve T


> >> I am new to IBM machines. We have IBM RS6000, running AIX 4.3.2.

> >> I have a script which automatically takes backup of the database at
> >> night. However I need a mechanism to find whether any tape is present in
> >> the tape drive. If it isn't, then I can bail out rather than invoking
> >> the backup program which assumes the tape to be present in the drive.
> >> This will be very useful when someone forgets to put a tape in the
> >> drive.

> >> Question: Is there a command in AIX which I can call from my shell
> >> script to find out whether the tape drive has any tape or not?

> >> Please email me the answer as I don't visit this ng.

> >> TIA.

> >> Ravi.

> >> Sent via Deja.com http://www.deja.com/
> >> Before you buy.