Solved

Test if tapes in drive in Script Help?

Posted on 1998-05-06
9
277 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
Get Database Help Now w/ Support & Database Audit

Keeping your database environment tuned, optimized and high-performance is key to achieving business goals. If your database goes down, so does your business. Percona experts have a long history of helping enterprises ensure their databases are running smoothly.

 
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

Technology Partners: 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!

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

632 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