john@wa3wbu.UUCP (John Gayman) (10/24/87)
Im running Microport Sys V/AT on an AT-clone. Can anyone give me a shell script for setting the Terminal type at login time. I use the same login for myself but throughout the day use several terminal types. Invaribly I forget to manually set TERM type and then VI, and well you know the rest :-) I would like a small script to stick on the end of .profile that would give me a one-line prompt at login time and ask me for my terminal type. Preferably if nothing were entered it would default to vt100. I attempted to write my own script and everything looked like it worked except the term type wouldnt actually get changed. Any ideas ? John
francus@cheshire.columbia.edu (Yoseff Francus) (10/25/87)
In article <155@wa3wbu.UUCP> john@wa3wbu.UUCP (John Gayman) writes: > > Im running Microport Sys V/AT on an AT-clone. Can anyone give me >a shell script for setting the Terminal type at login time. I use the >same login for myself but throughout the day use several terminal types. >Invaribly I forget to manually set TERM type and then VI, and well you >know the rest :-) > > I would like a small script to stick on the end of .profile that >would give me a one-line prompt at login time and ask me for my terminal >type. Preferably if nothing were entered it would default to vt100. > > I attempted to write my own script and everything looked like it >worked except the term type wouldnt actually get changed. Any ideas ? > > > John > I use the following lines at the beginning of my .profile and it works fine. If I don't specify any terminal it defaults to hds. echo "TERM (hds): \c";read TERM if [ "${TERM}" = "" ] then TERM=hds fi export TERM TERMCAP LOGNAME EDITOR This has worked under Berkeley Unix and Sys V UNIX, under bith Ksh and bsh. Yoseff ****************************************************************** yf In Xanadu did Kubla Khan a stately pleasure dome decree But only if the NFL to a franchise would agree. ARPA: francus@cs.columbia.edu UUCP: seismo!columbia!francus
avr@hou2d.UUCP (Adam V. Reed) (10/25/87)
In article <155@wa3wbu.UUCP>, john@wa3wbu.UUCP (John Gayman) writes: > > Im running Microport Sys V/AT on an AT-clone. Can anyone give me > a shell script for setting the Terminal type at login time. I use the > same login for myself but throughout the day use several terminal types. > Invaribly I forget to manually set TERM type and then VI, and well you > know the rest :-) > > I would like a small script to stick on the end of .profile that > would give me a one-line prompt at login time and ask me for my terminal > type. Preferably if nothing were entered it would default to vt100. > > I attempted to write my own script and everything looked like it > worked except the term type wouldnt actually get changed. Any ideas ? > > > John > The relevant script fragment is echo 'Terminal: \c' ; read TERM ; export TERM You can either put the above directly in your .profile, or put it in a file such as $HOME/termscript and add to your .profile the line . termscript This will cause it to be executed in your login shell. If you invoked your script with "$ termscript" instead of "$ . termscript" while testing, the script would be executed in a child shell, and your newly set $TERM would disappear when the child shell exited. In the future, please post your queries to "comp.unix.questions" and not "comp.unix.wizards", at least until you have a question that truly requires wizardly expertise. Adam Reed (hou2d!avr)
rupley@arizona.edu (John Rupley) (10/26/87)
In article <5093@columbia.edu>, francus@cheshire.columbia.edu (Yoseff Francus) writes: > In article <155@wa3wbu.UUCP> john@wa3wbu.UUCP (John Gayman) writes: > > > > Im running Microport Sys V/AT on an AT-clone. Can anyone give me > >a shell script for setting the Terminal type at login time. I use the > > > I use the following lines at the beginning of my .profile and > it works fine. If I don't specify any terminal it defaults to hds. > > echo "TERM (hds): \c";read TERM > if [ "${TERM}" = "" ] > then > TERM=hds > fi > export TERM TERMCAP LOGNAME EDITOR You can set TERM without the need for user response at logon, by including the following code in .profile and constructing a datafile, /etc/termfile, that associates a terminal type with a tty-port. The code works for microport sysV/AT. It is written for direct tty connections. For modem connections you might want to grep for logname and change the termfile appropriately. INCLUDE IN .PROFILE TERM=ansi aaa=`/bin/grep \`/bin/tty\` /etc/termfile | /usr/bin/cut -d" " -f3` if [ $aaa ] then TERM=$aaa fi export TERM CREATE /ETC/TERMFILE (EXAMPLE FOLLOWS) console /dev/console ansi cons1 /dev/cons1 ansi cons2 /dev/cons2 ansi cons3 /dev/cons3 ansi room1 /dev/tty4C otrona room2 /dev/tty4E otrona eric /dev/tty4B tvi john /dev/tty4D otrona John Rupley uucp: ..ihnp4!arizona!rupley voice: 602-325-4533
davidsen@steinmetz.steinmetz.UUCP (William E. Davidsen Jr) (10/27/87)
A solution was suggested to look at the output of /bin/tty for the terminal id, and do a lookup. Using "who am i" will allow this to work on BSD as well. set `who am i` # now $1 is user, $2 is port case $2 in con*) # this is the console ;; ttyXX) # any hardwired line of known type here ;; *) # dialin lines here case $1 in user1) # decode each user ;; case2) # and set type ;; *) # default, ask... echo "Enter terminal type:" read ttype esac esac TERM=$ttype ; export TERM Hope this helps. If you are only concerned with yourself, put this in your personal .profile and eliminate the user tests. For general use put in /etc/profile. Some csh user could post a version for csh, I haven't done the exercise. -- bill davidsen (wedu@ge-crd.arpa) {uunet | philabs | seismo}!steinmetz!crdos1!davidsen "Stupidity, like virtue, is its own reward" -me
don@seila.UUCP (Don Kossman) (10/28/87)
In article <155@wa3wbu.UUCP> john@wa3wbu.UUCP (John Gayman) writes: > > Im running Microport Sys V/AT on an AT-clone. Can anyone give me >a shell script for setting the Terminal type at login time. I use the >same login for myself but throughout the day use several terminal types. > I use the following on SCO Xenix; it uses a ".term" file to keep track of the last terminal you used: (put in your .profile) if [ -f .term ] then term=`cat .term` else term=vt100 fi tset -m $term:\?$term -s > .tset . .tset rm -f .tset echo $TERM > .term unset term -- Don Kossman, SEI Information Technology, Los Angeles usenet: {ccicpg!imt3b2 | peregrine!imt3b2 | sun!tsunama!tsunami}!seila!don