Solved

Test if tapes in drive in Script Help?

Posted on 1998-05-06
9
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

749 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