📄 ch05_03.htm
字号:
> variable (<ACLASS="linkend"HREF="ch05_04.htm"TITLE="Setting the TERMCAP Variable with tset ">5.4</A>)</SPAN>.(You must also issue the command <CODECLASS="literal">set noglob</CODE>,as explained in article<ACLASS="xref"HREF="ch06_09.htm"TITLE="Special C Shell Variables ">6.9</A>.)</P><PCLASS="para">To see what <EMCLASS="emphasis">tset</EM> can do, consider a case where the terminal's serialline is connected to a dialup modem, through which several differentusers might be connected, each using a different type ofterminal.Accordingly, the default terminal type in<EMCLASS="emphasis">/etc/ttytype</EM> should be set to <EMCLASS="emphasis">dialup</EM>.The <EMCLASS="emphasis">tset</EM> command couldthen be used inthe <EMCLASS="emphasis">.login</EM> file as follows, with the appropriate terminal typeset for each user:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">set noglobeval `tset -s -Q -m 'dialup:vt100'`</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-4940"></A>This means that if <EMCLASS="emphasis">ttytype</EM> says <EMCLASS="emphasis">dialup</EM>, use<EMCLASS="emphasis">vt100</EM> as the terminal type. A colon separates the<EMCLASS="emphasis">ttytype</EM> value and the value to which it is to be mapped.If a user wants to be prompted to be sure, place a question mark after the colon and before the mapped terminal type:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">set noglobeval `tset -s -Q -m 'dialup:?vt100'`</PRE></BLOCKQUOTE></P><PCLASS="para">The prompt will look like this:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">TERM = (vt100)</PRE></BLOCKQUOTE></P><PCLASS="para">If the user presses RETURN,the preferred terminal type will be used. Alternatively, anotherterminal type could be entered at that time.</P><PCLASS="para">You can cause <EMCLASS="emphasis">tset</EM> to prompt for a terminal typeeven without testing a generic entry like <EMCLASS="emphasis">dialup</EM>.Just specify the desired terminal type, preceded by a question mark,after the <EMCLASS="emphasis">-m</EM> option.For example:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">set noglobeval `tset -s -Q -m '?vt100'`</PRE></BLOCKQUOTE></P><PCLASS="para">It is also possible to specify different terminal types fordifferent line speeds. Say, forexample, that you normally used a Wyse-50 with a 9600-bpsmodem when dialing in from home, but used a portable PC witha VT100 terminal emulator and 2400-bps modem when you wereon the road. You might then use a <EMCLASS="emphasis">tset</EM> command like this:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">set noglobeval `tset -s -Q -m 'dialup@2400:vt100' wy50`</PRE></BLOCKQUOTE></P><PCLASS="para"> Assuming that the type is set in <EMCLASS="emphasis">ttytype</EM> as <EMCLASS="emphasis">dialup</EM>, <EMCLASS="emphasis">tset</EM> will use the type <EMCLASS="emphasis">vt100</EM> if at 2400 bpsand, if not, will use the type <EMCLASS="emphasis">wy50</EM>.</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-4970"></A>[Watch out for the linespeed switches.They don't work on a lot of networked systems - usually, the line speedat the computer's port is higher than the speed at the terminal.The same problem occurs, these days, with dialup modems that use datacompression. <EMCLASS="emphasis">-JP</EM> ]Various symbols can be used for line-speed calculations: </P><DLCLASS="variablelist"><DTCLASS="term"><CODECLASS="literal">@</CODE><CODECLASS="replaceable"><I>speed</I></CODE></DT><DDCLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-4980"></A>Means at the specified speed. </P></DD><DTCLASS="term"><CODECLASS="literal"><</CODE><CODECLASS="replaceable"><I>speed</I></CODE></DT><DDCLASS="listitem"><PCLASS="para">Means less than the specified speed.</P></DD><DTCLASS="term"><CODECLASS="literal">></CODE><CODECLASS="replaceable"><I>speed</I></CODE></DT><DDCLASS="listitem"><PCLASS="para">Means greater than the specified speed. </P></DD></DL><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-4995"></A>An exclamation point can precede theoperator to reverse the sense of the comparison.(For example,<CODECLASS="literal">!@1200</CODE> would mean at any speed other than 1200 bps.In the C shell, you have to type<SPANCLASS="link"><CODECLASS="literal">\!@1200</CODE> (<ACLASS="linkend"HREF="ch11_02.htm"TITLE="History in a Nutshell ">11.2</A>)</SPAN>instead.)</P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-5002"></A>Multiple <EMCLASS="emphasis">-m</EM> options can be specified; the first map to besatisfied will be used. If no match is found, a final valuespecified on the line without a <EMCLASS="emphasis">-m</EM> option (as in the above example) will be used. If no value is specified, the typein <EMCLASS="emphasis">/etc/ttytype</EM> will be used.</P><PCLASS="para">These changes may not always work; article<ACLASS="xref"HREF="ch42_03.htm"TITLE="Why Changing TERM Sometimes Doesn't Work ">42.3</A>explains why.Article<ACLASS="xref"HREF="ch41_09.htm"TITLE="Commands to Adjust Your Terminal ">41.9</A>has a script for adjusting your terminal.</P><DIVCLASS="sect1info"><PCLASS="SECT1INFO">- <SPANCLASS="authorinitials">TOR</SPAN> <SPANCLASS="bibliomisc">from O'Reilly & Associates' <CITECLASS="citetitle">termcap & terminfo</CITE>, Chapter 4</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_02.htm"TITLE="5.2 The Idea of a Terminal Database "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 5.2 The Idea of a Terminal Database "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_04.htm"TITLE="5.4 Setting the TERMCAP Variable with tset "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 5.4 Setting the TERMCAP Variable with tset "BORDER="0"></A></TD></TR><TR><TDALIGN="LEFT"VALIGN="TOP"WIDTH="172">5.2 The Idea of a Terminal Database </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.4 Setting the TERMCAP Variable 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 & 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 + -