Solved

Test if tapes in drive in Script Help?

Posted on 1998-05-06
9
218 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
Comment Utility
#! /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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 51

Expert Comment

by:ahoffmann
Comment Utility
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
Comment Utility
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
Comment Utility
#! /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
Comment Utility
~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
Comment Utility
~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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

743 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

10 Experts available now in Live!

Get 1:1 Help Now