Operating System - HP-UX
1832058 Members
3128 Online
110034 Solutions
New Discussion

Prompting for terminal type

 
SOLVED
Go to solution
Linda_52
Occasional Contributor

Prompting for terminal type

I am sure this is very simple, but none of my amateur attempts have worked. I need a prompt asking me what type terminal I have. I have set
everything in my .profile that I can think of.
10 REPLIES 10
G. Vrijhoeven
Honored Contributor

Re: Prompting for terminal type

Hi,

# Set terminal type
echo "terminal: \c"
read TERM
case $TERM in
300) stty cr2 nl0 tabs; tabs;;
300s) stty cr2 nl0 tabs; tabs;;
450) stty cr2 nl0 tabs; tabs;;
hp) stty cr0 nl0 tabs; tabs;;
745|735) stty cr1 nl] -tabs; TERM=745;;
43) stty cr1 nl0 -tabs;;
*) echo "$TERM unknown";;
esac


Gideon
Steven E. Protter
Exalted Contributor
Solution

Re: Prompting for terminal type

echo "Enter terminal type:"
read ttype

TERM=$ttype
export TERM

SEP+
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Vitek Pepas
Valued Contributor

Re: Prompting for terminal type

I once used this in profiles:

print "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
print -n "Terminal Type (v/V=vt220scc; a/A=aixterm)?"
read Type
if [ "$Type" = "v" ] || [ "$Type" = "V" ]
then
export TERM=vt220scc
elif [ "$Type" = "a" ] || [ "$Type" = "A" ]
then
export TERM=aixterm
else echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo "\t\t\t Wrong choice !!!\007"
sleep 3
fi
A. Clay Stephenson
Acclaimed Contributor

Re: Prompting for terminal type

If you are running one of the standard HP terminal types then perhaps the easist method os to include a call to ttytype. Man 1 ttytype for details.

As for reading a termional type in .profile, nothing more complicated than:
echo "Enter Terminal Type: \c"
read TTYPE
is required. The first question to ask is "Are you actually running .profile?" . If you a doing a CDE login then you need to makesure that the line "DTSOURCEPROFILE=true" is not commented out in .dtprofile.


If it ain't broke, I can fix that.
Hein van den Heuvel
Honored Contributor

Re: Prompting for terminal type

WHY prompt for terminal type if you can have the system figure it out?!

I mean, there may well be a reason to ask explicitly, but perhaps an automated procedure is nicer for your users?

Check out 'man tttype'

Here is what my /etc/profile (standard) reads:

# set term if it's not set

if [ "$TERM" = "" -o "$TERM" = "unknown" -o "$TERM" = "dialup" \
-o "$TERM" = "network" ]
then
eval `ttytype -s -a`
fi

export TERM


You may also want to study 'man tset', 'man tty' and 'man stty' for further toughts.

Hth,
Hein.
Bill Hassell
Honored Contributor

Re: Prompting for terminal type

If you are running a standard /etc/profile and .profile, then the prompt is coming from ttytype. And the reason is that your terminal is not just dumb, it's braindead. Seriously, here's what ttytype is doing. All terminals and virtually all emulators built in the last 20 years can answer back automatically. By sending some special queries, one of the queries will trigger a response from the terminal. Each response is given 1 second to reply. If all responses are ignored then ttytype asks for the type of terminal you are using.

So the reason you are asked for a terminal is that whatever you are using is not a Wyse, VT100-style or HP terminal. Or you have configured the terminal or emulator not to respond to status queries. You can comment out the ttytype line but you'll only be abe to use the command line. Running an editing program like like vi requires a valid TERM setting. TERM is a translator that tells programs like vi how to move around on the screen. Manually setting TERM to a random value (ie, no connection the the real terminal you are using) will cause vi and other menu programs to fail.

What type of terminal or emulator are you using?


Bill Hassell, sysadmin
Elmar P. Kolkman
Honored Contributor

Re: Prompting for terminal type

A lot of the examples should work... You could also create a menu when ttytype doesn't correctly respond.

Test the ttytype command on your terminals before using it. There are known issues with terminals that hang when ttytype tries to identify them.

One thing to bear in mind: DONT PUT IT IN /etc/profile !!! Or check if you have a valid tty before requesting the ttytype. The tty command can be used for this.

Any script you run with su - in for instance a startup script (oracle is an example) will have problems with this...
Every problem has at least one solution. Only some solutions are harder to find.
Jeroen Peereboom
Honored Contributor

Re: Prompting for terminal type

Putting ttytype in .profile may also cause additional output in cron jobs, for example if you have something like 'su - ....' as one of your cron commands.

JP
Bill Hassell
Honored Contributor

Re: Prompting for terminal type

Jeroen is wuite right. .profile and /etc/profile must be rewritten to exclude interactive terminal commands such as ttytype, tset, tabs and tput. You can use tty as in this example:

if tty -s
then
eval ($ttytype -s)
tabs
tput reset
fi


Bill Hassell, sysadmin
Linda_52
Occasional Contributor

Re: Prompting for terminal type

Thanks to all who responded. Steven, your suggestion worked best for me.