Solved

Test if tapes in drive in Script Help?

Posted on 1998-05-06
9
233 Views
Last Modified: 2013-12-26
I am trying to test if a tape is inserted at the top of my script
on HP-UX 10.20 as the script will fail, I think 'mt' is the only
way can you help with the syntax?

if /usr/bin/mt -t /dev/rmt/0m rew
        then echo "continue" <- then i want this to continue on with the rest of script..........                      
fi                              
else echo "no tape in drive";exit                

.....REST of Script
......
0
Comment
Question by:red031197
  • 4
  • 3
  • 2
9 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1292883
#! /bin/csh -f

mt -t /dev/rmt/0m rew
if ($status != 0) then
    echo "no tape in drive"
    exit 1
endif

# keep in mind that this is not realy true,
# we can say if mt returns 0 it then rewinded the tape
0
 
LVL 2

Expert Comment

by:gormenghast
ID: 1292884
Hi
You have the same question posted twice -- delete the other one.

Here is a section of a script I use myself which is the same as ahoffmans answer but it sounds an alarm to let someone know the tape needs changing and then continues with the rest of the script, once there is a tape in the drive.

tape=/dev/rmt/1lbn
echo "$tape\n\n\n" >> $log
YN=x
until [ $YN = y ]
      do
      mt -f ${tape} status
      stat=$?
      if [ $stat = 1 ]
      then
            echo "PUT ${tapeReq} TAPE IN DRIVE "> /dev/console
            /app/bin/play -v100 /usr/demo/SOUND/sounds/doorbell.au
            sleep 3
            echo
            YN=n
            else
            YN=y
            echo TAPE OK > /dev/console
            /usr/bin/mt -f ${tape} status > /dev/console
      fi
done

 
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 1292885
gormenghast, I actually only have HP-UX 9.x and this has a
very purly version of mt: not status command :-(
Has this changed for HP-UX 10.x ?
0
 
LVL 2

Expert Comment

by:gormenghast
ID: 1292886
Hi ahoffman
Im afraid I don't know about HP-UX, as I use Solaris 2.x on SUN Sparcs. The mt commands available are:

eof, weof, fsf, fsr, bsf, bsr, nbsf, asf eom, rewind, offline, rewoffl, status, retension, erase.

A general UNIX sysadmin book I have (Essential System Administration -- O'Reilly) talks about "standard UNIX" providing the mt command and mentions status and goes on to say that the Solaris version of mt includes an asf subcommand. So possibly a newer version of HP-Ux would include the status command.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 51

Expert Comment

by:ahoffmann
ID: 1292887
hmm, that's one of the standards which every vendor interprets
himself (HP in this case)-:  they just all have mt, that's all.
HP-UX's mt is completely different from other UNIXs, it has no
status command, and all others are 3-leter mnemonics.
0
 
LVL 2

Author Comment

by:red031197
ID: 1292888
this is fine but one slight prob. I wanted to append by exsisting backup script which is #! /sbin/sh?????
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 150 total points
ID: 1292889
#! /bin/sh

     mt -t /dev/rmt/0m rew
     if [ $? -ne 0 ]; then
         echo "no tape in drive"
         exit 1
     fi
0
 
LVL 2

Author Comment

by:red031197
ID: 1292890
~Thanks my good man

note: it has to /sbin/sh on HP-UX as now user in single user
this is a posix shell on hp-ux 10.20
0
 
LVL 2

Author Comment

by:red031197
ID: 1292891
~Thanks my good man

note: it has to /sbin/sh on HP-UX as now usr in single user
this is a posix shell on hp-ux 10.20
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now