Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Test if tapes in drive in Script Help?

Posted on 1998-05-06
9
Medium Priority
?
283 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
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

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…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

730 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