[comp.sys.sgi] mt status option

kcables@RELAY.NSWC.NAVY.MIL (12/12/90)

Hi everyone,
	I'm trying to write a shell script in which I need to find
out if the 8mm tape is in the drive.  Whenever I execute the
mt command with the status option, the output always appears at
my terminal, regardless of whether its output is redirected or piped,
or even if it's in a shell script on the right side of an equal sign.
Does anyone know how this output can be redirected so that I can
capture the 'status' information?  I tried

	mt -t /dev/mt/tps0d6 status > dum

	mt -t /dev/mt/tps0d6 status | grep Status

	and in a shell script:

	xxx=`mt -t /dev/mt/tps0d6 status`

All of the above display the output at my terminal.  Thanks
in advance.

kcables@relay.nswc.navy.mil

merritt@iris613.gsfc.nasa.gov (John H Merritt) (12/13/90)

In article <9012111454.aa09992@VGR.BRL.MIL> kcables@RELAY.NSWC.NAVY.MIL writes:
>mt command with the status option, the output always appears at
>my terminal, regardless of whether its output is redirected or piped,
It is writing to stderr;  you must also redirect stderr.

>	mt -t /dev/mt/tps0d6 status > dum
	mt -t /dev/mt/tps0d6 status >& dum
                               
>	mt -t /dev/mt/tps0d6 status | grep Status
	mt -t /dev/mt/tps0d6 status |& grep Status

>	xxx=`mt -t /dev/mt/tps0d6 status`
    set xxx = `mt -t /dev/mt/tps0d6 status |& cat`

              John H. Merritt --> merritt@iris613.gsfc.nasa.gov
              Applied Research Corporation at NASA/GSFC
              "Yesterday I knew nothing, today I know that."

LEONARDZ@VM.UOGUELPH.CA (Len Zaifman) (12/13/90)

On Tue, 11 Dec 90 14:52:27 EST you said:
>Hi everyone,
>	I'm trying to write a shell script in which I need to find
>out if the 8mm tape is in the drive.  Whenever I execute the
>mt command with the status option, the output always appears at
>my terminal, regardless of whether its output is redirected or piped,
>or even if it's in a shell script on the right side of an equal sign.
>Does anyone know how this output can be redirected so that I can
>capture the 'status' information?  I tried
>
>	mt -t /dev/mt/tps0d6 status > dum
>
>	mt -t /dev/mt/tps0d6 status | grep Status
>
>	and in a shell script:
>
>	xxx=`mt -t /dev/mt/tps0d6 status`
>
>All of the above display the output at my terminal.  Thanks
>in advance.

   In csh use >& to redirect the stderr output to a file :

   See example below :

< 24 nic.uoguelph.ca /cs/leonardz> mt -t /dev/nrxb status
Controller: SCSI                                        |  This
Device: EXABYTE: EXB-8200        425A                   |  appears
Status: 0x200                                           |  on
Media : Not READY                                       |  terminal
< 25 nic.uoguelph.ca /cs/leonardz> mt -t /dev/nrxb status >& mystat
< 26 nic.uoguelph.ca /cs/leonardz> cat mystat
Controller: SCSI
Device: EXABYTE: EXB-8200        425A
Status: 0x200
Media : Not READY
< 27 nic.uoguelph.ca /cs/leonardz>


>
>kcables@relay.nswc.navy.mil

                                                         Regards, Len Zaifman

Len Zaifman
Information Technology Coordinator,College of Physical and Engineering Science
Department of Computing Services
University of Guelph
Guelph,Ontario.  N1G 2W1
(519)821-4120 xt 6566
email : LeonardZ@VM.UOGUELPH.CA

kcables@RELAY.NSWC.NAVY.MIL (12/13/90)

Thanks, Len.  That's what I figured out 5 minutes after I posted it.
I know, read my Unix book.

	Kathryn