[net.micro.pc] How to tell if stdout is console

connery@bnrmtv.UUCP (Glenn Connery) (04/06/86)

...
In writing a number of utilities it has become desirable to be able to
tell automatically if stdout has been redirected or not.  For example
in writing a directory lister which uses color through the BIOS it
should automatically go back to normal DOS I/O if the device is not
the console.  I can do this through fstat or isatty in MSC 3.0 if the
redirected device is a file and not a device, but I can't tell if the
user has redirected stdout to the printer or another device.

Any ideas?
-- 

Glenn Connery, Bell Northern Research, Mountain View, CA
{hplabs,amdahl,3comvax}!bnrmtv!connery

dlnash@ut-ngp.UUCP (Donald L. Nash) (04/07/86)

> In writing a number of utilities it has become desirable to be able to
> tell automatically if stdout has been redirected or not.  For example
> in writing a directory lister which uses color through the BIOS it
> should automatically go back to normal DOS I/O if the device is not
> the console.  I can do this through fstat or isatty in MSC 3.0 if the
> redirected device is a file and not a device, but I can't tell if the
> user has redirected stdout to the printer or another device.
>
> Any ideas?
> -- 
>
> Glenn Connery, Bell Northern Research, Mountain View, CA
> {hplabs,amdahl,3comvax}!bnrmtv!connery


Use the IOCTL DOS function.  Look it up in the DOS manual, it is
function 0x44.  You want subfunction 0.  I needed to determine the same
thing about stdin at wone time.  This will do it.  I believe that MSC
3.0 will allow you to make direct calls to DOS, won't it?  I haven't
used MSC, but in CII C86, there is a function sysint21() which allows
you to make calls to DOS.

Hope this helps...

					Don Nash

UUCP:    ...!{ihnp4,allegra,seismo!ut-sally}!ut-ngp!dlnash
APRA:    dlnash@ngp.CC.UTEXAS.EDU
BITNET:  cceu001@utadnx


        "If you can't say something nice, then don't" -- anonymous

bc@cyb-eng.UUCP (Bill Crews) (04/09/86)

> In writing a number of utilities it has become desirable to be able to
> tell automatically if stdout has been redirected or not.  For example
> in writing a directory lister which uses color through the BIOS it
> should automatically go back to normal DOS I/O if the device is not
> the console.  I can do this through fstat or isatty in MSC 3.0 if the
> redirected device is a file and not a device, but I can't tell if the
> user has redirected stdout to the printer or another device.
> 
> Any ideas?
> -- 
> Glenn Connery, Bell Northern Research, Mountain View, CA

Bit 1 (i.e., mask = 0x0002) of the IOCTL word (interrupt 0x21, function
0x44) is labeled ISCOT in the DOS Technical Reference Manual, which means
that "this device is the console output".  It would seem that this is the bit
you need to interrogate, but I don't know if MSC 3.0 has a library function
that passes it through.

-- 
	- bc -

..!{seismo,topaz,gatech,nbires,ihnp4}!ut-sally!cyb-eng!bc  (512) 835-2266