⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ch05_10.htm

📁 the unix power tools
💻 HTM
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 5] 5.10 Finding What Terminal Names You Can Use </TITLE><METANAME="DC.title"CONTENT="UNIX Power Tools"><METANAME="DC.creator"CONTENT="Jerry Peek, Tim O'Reilly &amp; Mike Loukides"><METANAME="DC.publisher"CONTENT="O'Reilly &amp; Associates, Inc."><METANAME="DC.date"CONTENT="1998-08-04T21:33:12Z"><METANAME="DC.type"CONTENT="Text.Monograph"><METANAME="DC.format"CONTENT="text/html"SCHEME="MIME"><METANAME="DC.source"CONTENT="1-56592-260-3"SCHEME="ISBN"><METANAME="DC.language"CONTENT="en-US"><METANAME="generator"CONTENT="Jade 1.1/O'Reilly DocBook 3.0 to HTML 4.0"><LINKREV="made"HREF="mailto:online-books@oreilly.com"TITLE="Online Books Comments"><LINKREL="up"HREF="ch05_01.htm"TITLE="5. Setting Up Your Terminal"><LINKREL="prev"HREF="ch05_09.htm"TITLE="5.9 Setting Your Erase, Kill, and Interrupt Characters "><LINKREL="next"HREF="ch05_11.htm"TITLE="5.11 Initializing the Terminal with tset "></HEAD><BODYBGCOLOR="#FFFFFF"TEXT="#000000"><DIVCLASS="htmlnav"><H1><IMGSRC="gifs/smbanner.gif"ALT="UNIX Power Tools"USEMAP="#srchmap"BORDER="0"></H1><MAPNAME="srchmap"><AREASHAPE="RECT"COORDS="0,0,466,58"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="467,0,514,18"HREF="jobjects/fsearch.htm"ALT="Search this book"></MAP><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_09.htm"TITLE="5.9 Setting Your Erase, Kill, and Interrupt Characters "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.9 Setting Your Erase, Kill, and Interrupt Characters "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 5<BR>Setting Up Your Terminal</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_11.htm"TITLE="5.11 Initializing the Terminal with tset "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 5.11 Initializing the Terminal with tset "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-0077">5.10 Finding What Terminal Names You Can Use </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-5495"></A><ACLASS="indexterm"NAME="AUTOID-5496"></A><ACLASS="indexterm"NAME="AUTOID-5497"></A><ACLASS="indexterm"NAME="AUTOID-5500"></A><ACLASS="indexterm"NAME="UPT-ART-77-IX-CONFIGURING-TERMINALS"></A><ACLASS="indexterm"NAME="UPT-ART-77-IX-TERMINALS-CONFIGURING"></A>A program that wants to make use of the terminal capabilitydatabase selects an entry according to the value of the <EMCLASS="emphasis">TERM</EM><ACLASS="indexterm"NAME="AUTOID-5509"></A><SPANCLASS="link">environment variable (<ACLASS="linkend"HREF="ch06_01.htm#UPT-ART-1170"TITLE="What Environment Variables Are Good For ">6.1</A>)</SPAN>.This variable is typically set when auser logs in. A second variable, either<SPANCLASS="link"><EMCLASS="emphasis">TERMCAP</EM> (<ACLASS="linkend"HREF="ch05_04.htm"TITLE="Setting the TERMCAP Variable with tset ">5.4</A>)</SPAN>or<EMCLASS="emphasis">TERMINFO</EM>, may also be set, if it is desirable to point toa terminal description that is not in the standard location.</P><PCLASS="para">It's easy enoughto find out what terminal type the system thinks you are currentlyusing. Simply type:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>echo $TERM</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">If nothing is printed, <EMCLASS="emphasis">TERM</EM> has not been set. (In the C shell,the message <CODECLASS="literal">TERM:</CODE> <CODECLASS="literal">Undefined</CODE> <CODECLASS="literal">variable</CODE> will be printed.)</P><PCLASS="para">It's also easy enough to set the terminal type.This is typically done when the user logs in butcan be done from the command line as follows:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>TERM=wy50; export TERM</B></CODE>% <CODECLASS="userinput"><B>setenv TERM wy50</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">But what if you sit down at a strange terminal and want to set theterminal type? How do you know what terminal name to use as the valueof <EMCLASS="emphasis">TERM</EM>?</P><PCLASS="para">The terminal names to which <EMCLASS="emphasis">TERM</EM> can legitimately be setcan be determined by searching through <EMCLASS="emphasis">/etc/termcap</EM> orby listing the names of files in the <EMCLASS="emphasis">/usr/lib/terminfo</EM>directory hierarchy.</P><PCLASS="para">The <EMCLASS="emphasis">termcap</EM> terminal database is stored in the singlefile <EMCLASS="emphasis">/etc/termcap</EM>.It is an ASCII file: all theinformation it contains is readable, if not immediatelycomprehensible. Each entry consists of a list of names forthe terminal, followed by a list of the terminal's capabilities.</P><PCLASS="para">The first line of each entry shows several different names, or aliases, for the terminal. At least one of the nameswill usually reflect themanufacturer's shorthand name for the terminal, but a longname is usually included as well, so you can simply search forthe manufacturer's name to get started. For example, if you were using a Wyse Technologies Wyse-50, you could check tomake sure that a terminal description for that terminalexisted in the <EMCLASS="emphasis">termcap</EM> database by typing:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>grep Wyse /etc/termcap</B></CODE>n9|wy50|Wyse Technology WY-50:\</PRE></BLOCKQUOTE></P><PCLASS="para">One or more lines like the one shown in the preceding example should beprinted (if any matching entries are found). Each line will showseveral names for the terminal, separated by vertical bars (<CODECLASS="literal">|</CODE>). The second name, <CODECLASS="literal">wy50</CODE>, is the one mostcommonly used as the value of <EMCLASS="emphasis">TERM</EM>.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-5548"></A>The compiled <EMCLASS="emphasis">terminfo</EM> database is stored ina directory hierarchy under <EMCLASS="emphasis">/usr/lib/terminfo</EM>.Each terminal entry is compiled (by a program called<EMCLASS="emphasis">tic</EM>) and stored in a separate file. Allterminals whose names beginwith the letter &quot;a&quot; arestored in the directory <EMCLASS="emphasis">/usr/lib/terminfo/a</EM>, and so onthrough the alphabet.[1]<SPANCLASS="link">Links (<ACLASS="linkend"HREF="ch18_03.htm"TITLE="Files with Two or More Names">18.3</A>)</SPAN>are used so that the terminaldescription can be accessed with any one of several names.[The<ACLASS="indexterm"NAME="AUTOID-5559"></A><SPANCLASS="link"><EMCLASS="emphasis">ls -R</EM> (<ACLASS="linkend"HREF="ch16_04.htm"TITLE="List All Subdirectories with ls -R ">16.4</A>)</SPAN>command will list all the descriptions at once.A command like<SPANCLASS="link"><EMCLASS="emphasis">find -name&nbsp;'*xxx*' -print</EM> (<ACLASS="linkend"HREF="ch17_04.htm"TITLE="Looking for Files with Particular Names ">17.4</A>)</SPAN>will find descriptions with a certain brand or model <EMCLASS="emphasis">xxx</EM> in thename. <EMCLASS="emphasis">-JP</EM>&nbsp;]</P><BLOCKQUOTECLASS="footnote"><PCLASS="para">[1] The source is sometimes provided by some systems in<EMCLASS="emphasis">/usr/lib/terminfo.ti</EM>.Entries can be decompiled or displayed with a program called <EMCLASS="emphasis">infocmp</EM>.</P></BLOCKQUOTE><PCLASS="para">So, on a system supporting <EMCLASS="emphasis">terminfo</EM>, you would look forthe entry with the <EMCLASS="emphasis">ls</EM> command: </P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>ls /usr/lib/terminfo/w</B></CODE>wy-50wy100wy50wyse-50wyse50</PRE></BLOCKQUOTE></P><PCLASS="para">You should use the name of the appropriate file for the value of <EMCLASS="emphasis">TERM</EM>.</P><PCLASS="para">If it is not obvious from the name of the file which entryto use, you can use the following command to print outthe long name of the terminal:<ACLASS="indexterm"NAME="AUTOID-5577"></A></P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>tput -T</B></CODE><CODECLASS="replaceable"><I>name</I></CODE> <CODECLASS="userinput"><B>longname</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">&#13;For example:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">$ <CODECLASS="userinput"><B>tput -Twy50 longname</B></CODE>Wyse Technologies Wy-50</PRE></BLOCKQUOTE></P><PCLASS="para">You should be aware that for a terminal with configurableoptions (such as a terminal with an 80- or 132-column mode),there may be several <EMCLASS="emphasis">termcap</EM> or <EMCLASS="emphasis">terminfo</EM>entries. Until you know enough aboutthe terminal database to compare the entries and find outhow they differ, you will simply need to take your chances.Experiment with each of the entries and see which works best.Article<ACLASS="xref"HREF="ch41_11.htm"TITLE="How termcap and terminfo Describe Terminals ">41.11</A>explains more about the format of <EMCLASS="emphasis">termcap</EM> and <EMCLASS="emphasis">terminfo</EM> entries.[If none of them seem to work, setting <EMCLASS="emphasis">TERM</EM> to a name like<EMCLASS="emphasis">dumb</EM> or <EMCLASS="emphasis">unknown</EM> will give you a basic setup whileyou check other entries.The <EMCLASS="emphasis">vi</EM> editor will use its<SPANCLASS="link">open mode (<ACLASS="linkend"HREF="ch30_36.htm"TITLE="The ex Open Mode Can Be Handy ">30.36</A>)</SPAN>and pagers like<SPANCLASS="link"><EMCLASS="emphasis">less</EM> (<ACLASS="linkend"HREF="ch25_04.htm"TITLE='The "less&quot; Pager: More than "more&quot;'>25.4</A>)</SPAN>will complain a little, but you should be able to get by.<EMCLASS="emphasis">-JP</EM>&nbsp;]</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">TOR</SPAN> <SPANCLASS="bibliomisc">from O'Reilly &amp; Associates' <CITECLASS="citetitle">termcap &amp; terminfo</CITE>, Chapter 2</SPAN></P></DIV></DIV><DIVCLASS="htmlnav"><P></P><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><TABLEWIDTH="515"BORDER="0"CELLSPACING="0"CELLPADDING="0"><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_09.htm"TITLE="5.9 Setting Your Erase, Kill, and Interrupt Characters "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.9 Setting Your Erase, Kill, and Interrupt Characters "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="book"HREF="index.htm"TITLE="UNIX Power Tools"><IMGSRC="gifs/txthome.gif"SRC="gifs/txthome.gif"ALT="UNIX Power Tools"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch05_11.htm"TITLE="5.11 Initializing the Terminal with tset "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 5.11 Initializing the Terminal with tset "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">5.9 Setting Your Erase, Kill, and Interrupt Characters </TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><ACLASS="index"HREF="index/idx_0.htm"TITLE="Book Index"><IMGSRC="gifs/index.gif"SRC="gifs/index.gif"ALT="Book Index"BORDER="0"></A></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172">5.11 Initializing the Terminal with tset </TD></TR></TABLE><HRALIGN="LEFT"WIDTH="515"TITLE="footer"><IMGSRC="gifs/smnavbar.gif"SRC="gifs/smnavbar.gif"USEMAP="#map"BORDER="0"ALT="The UNIX CD Bookshelf Navigation"><MAPNAME="map"><AREASHAPE="RECT"COORDS="0,0,73,21"HREF="../index.htm"ALT="The UNIX CD Bookshelf"><AREASHAPE="RECT"COORDS="74,0,163,21"HREF="index.htm"ALT="UNIX Power Tools"><AREASHAPE="RECT"COORDS="164,0,257,21"HREF="../unixnut/index.htm"ALT="UNIX in a Nutshell"><AREASHAPE="RECT"COORDS="258,0,321,21"HREF="../vi/index.htm"ALT="Learning the vi Editor"><AREASHAPE="RECT"COORDS="322,0,378,21"HREF="../sedawk/index.htm"ALT="sed &amp; awk"><AREASHAPE="RECT"COORDS="379,0,438,21"HREF="../ksh/index.htm"ALT="Learning the Korn Shell"><AREASHAPE="RECT"COORDS="439,0,514,21"HREF="../lrnunix/index.htm"ALT="Learning the UNIX Operating System"></MAP></DIV></BODY></HTML>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -