how an application may find out CGI device type

Suvajit Gupta sgupta at geo4.rdrc.rpi.edu
Mon Jan 15 14:45:19 AEST 1990


I have an interactive graph plotting program which I would like to run
both inside as well as outside of SunView.  Also, it should be able to
detect whether it is running from a non-Sun terminal (as in rlogin), or
whether the Sun has a monochrome/color monitor.  This is necessary to call
NORMAL_VWSURF with the appropriate frame buffer device.

  Currently, I open a pipeline to the following shell script:

[[Ed's Note: It bothers me a little to post something that carries a copyright.
In the future, I probably will not post copyrighted material since articles
in Sunspots are considered to be "in the public domain" -bdg]]

#! /bin/sh
##
##  Copyright (C)       R P I   1989
##
##  devtp: finds out the type of terminal
##
##      0 if not a SUN terminal
##      1 for monochrome SUN
##      2 for color SUN
##      3 for monochrome SUN running windows
##      4 for color SUN running windows
##

PATH=/bin:/usr/bin

# See if remotely logged in
if ( who am i | grep -s '(' )
then
   echo 0; exit
fi

# See if not a SUN terminal
case $TERM in
   sun*) ;;
   *) echo 0; exit;;
esac

if [ `tty` != "/dev/console" ] # running windows
then
   if ( grep -s "cg[a-z]*0" /usr/adm/messages )
   then
      echo 4
   else
      echo 3
   fi
else                          # not running windows
   if ( grep -s "cg[a-z]*0" /usr/adm/messages )
   then
      echo 2
   else
      echo 1
   fi
fi


Is there any better way of doing this?  Any help would be greatly
appreciated.

Suvajit Gupta       email: sgupta at rdrc.rpi.edu        phone: (518)-276-4079



More information about the Comp.sys.sun mailing list