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

📄 ch42_04.htm

📁 the unix power tools
💻 HTM
📖 第 1 页 / 共 2 页
字号:
<HTML><!--Distributed by F --><HEAD><TITLE>[Chapter 42] 42.4 Checklist for Resetting a Messed Up Terminal </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:52:26Z"><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="ch42_01.htm"TITLE="42. Problems with Terminals"><LINKREL="prev"HREF="ch42_03.htm"TITLE="42.3 Why Changing TERM Sometimes Doesn't Work "><LINKREL="next"HREF="ch42_05.htm"TITLE="42.5 Checklist: Screen Size Messed Up? "></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="ch42_03.htm"TITLE="42.3 Why Changing TERM Sometimes Doesn't Work "><IMGSRC="gifs/txtpreva.gif"SRC="gifs/txtpreva.gif"ALT="Previous: 42.3 Why Changing TERM Sometimes Doesn't Work "BORDER="0"></A></TD><TDALIGN="CENTER"VALIGN="TOP"WIDTH="171"><B><FONTFACE="ARIEL,HELVETICA,HELV,SANSERIF"SIZE="-1">Chapter 42<BR>Problems with Terminals</FONT></B></TD><TDALIGN="RIGHT"VALIGN="TOP"WIDTH="172"><ACLASS="SECT1"HREF="ch42_05.htm"TITLE="42.5 Checklist: Screen Size Messed Up? "><IMGSRC="gifs/txtnexta.gif"SRC="gifs/txtnexta.gif"ALT="Next: 42.5 Checklist: Screen Size Messed Up? "BORDER="0"></A></TD></TR></TABLE>&nbsp;<HRALIGN="LEFT"WIDTH="515"TITLE="footer"></DIV><DIVCLASS="SECT1"><H2CLASS="sect1"><ACLASS="title"NAME="UPT-ART-0059">42.4 Checklist for Resetting a Messed Up Terminal </A></H2><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46778"></A><ACLASS="indexterm"NAME="AUTOID-46781"></A>Gremlins (like line noise on a modem, a bug in a program, a really long lineof output, non-printable characters in a file you <EMCLASS="emphasis">cat</EM> to yourscreen, etc.) can sneak into your system somewhere and mess up yourterminal screen or window.The screen could have a bunch of flashing junk, the character set couldturn into hieroglyphics, words could start coming out underlined or ininverse video, the line could lock up... well, there are lots of possibilities.</P><PCLASS="para">Here's a rough list of things to try.This might be worth reading through right now.Some things in here need to be ready <EMCLASS="emphasis">before</EM> your terminal locks up.</P><ULCLASS="itemizedlist"><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46789"></A><ACLASS="indexterm"NAME="AUTOID-46791"></A>If you can get to a shell prompt (<CODECLASS="literal">%</CODE> or <CODECLASS="literal">$</CODE>),the first command you should try is probably:</P><PCLASS="para"><TABLECLASS="screen.co"BORDER="1"><TR><THVALIGN="TOP"><PRECLASS="calloutlist"><ACLASS="co"HREF="ch22_18.htm"TITLE="22.18 Clear Your Terminal for Security, to Stop Burn-in ">clear</A> <ACLASS="co"HREF="ch41_10.htm"TITLE="41.10 Using terminfo Capabilities in Shell Programs ">tput</A> </PRE></TH><TDVALIGN="TOP"><PRECLASS="screen">% <CODECLASS="userinput"><B>clear</B></CODE>   <ICLASS="lineannotation">systems with termcap</I>% <CODECLASS="userinput"><B>tput clear</B></CODE>   <ICLASS="lineannotation">systems with terminfo</I></PRE></TD></TR></TABLE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46804"></A>That will try to erase the screen and may also cancel other problems likeinverse video.</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46808"></A><ACLASS="indexterm"NAME="AUTOID-46810"></A>If running <EMCLASS="emphasis">clear</EM> doesn't clear up your screen completely and yourterminal has a setupmenu, look for a &quot;clear screen&quot; function and try it.(If you don't know how your terminal's setup mode works, find themanual or find an expert.Write down the steps and keep them close to your terminal.)</P></LI><LICLASS="listitem"><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46816"></A><ACLASS="indexterm"NAME="AUTOID-46818"></A>If you have a shell prompt and you're on a system using <EMCLASS="emphasis">terminfo</EM>, trythese commands.Don't use <EMCLASS="emphasis">tput init</EM> unless <EMCLASS="emphasis">tput reset</EM> doesn't fix things:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>tput reset</B></CODE>% <CODECLASS="userinput"><B>tput init</B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para">If you're using a <EMCLASS="emphasis">termcap</EM> system, there's no command quite likethose two.You can simulate them by making an<SPANCLASS="link">alias (<ACLASS="linkend"HREF="ch10_02.htm"TITLE="Aliases for Common Commands ">10.2</A>)</SPAN>that runs the<SPANCLASS="link"><EMCLASS="emphasis">tset</EM> (<ACLASS="linkend"HREF="ch05_04.htm"TITLE="Setting the TERMCAP Variable with tset ">5.4</A>)</SPAN>command from your login setup files.(Why not do it now, for the next time you get into this mess?)Here's a simple alias:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">alias newterm 'set noglob; eval `tset -srQ \!*`; unset noglob'</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46835"></A>The <EMCLASS="emphasis">tset</EM> command usually sends resetting or initialization commandsto your terminal.</P></LI><LICLASS="listitem"><PCLASS="para">If every character you type shows up on a different line,characters don't appear as you type them,a RETURNdoes nothing or prints a <CODECLASS="literal">^M</CODE> on your screen,the backspace, interrupt, and kill keys don't work, or lines</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">jump down          the screen                     like this</PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46844"></A>you've probably got trouble with the settings of your port(UNIX terminal device).One of the following commands can make your terminal usable.It might not be set up the way you're used to, but at least you'll be able to log out and log in again:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">% <CODECLASS="userinput"><B>reset</B></CODE>% <CODECLASS="userinput"><B><KBDCLASS="keycap">[CTRL-j]</KBD> reset <KBDCLASS="keycap">[CTRL-j]</KBD></B></CODE>% <CODECLASS="userinput"><B>stty sane</B></CODE>% <CODECLASS="userinput"><B> <KBDCLASS="keycap">[CTRL-j]</KBD> stty sane <KBDCLASS="keycap">[CTRL-j]</KBD></B></CODE></PRE></BLOCKQUOTE></P><PCLASS="para"><ACLASS="indexterm"NAME="AUTOID-46858"></A>(If your terminal has a <KBDCLASS="keycap">[LINEFEED]</KBD> key, you can use it instead of<KBDCLASS="keycap">[CTRL-j]</KBD>.)</P><PCLASS="para">If the system says that those commands don't exist or are an &quot;unknown mode,&quot;you should make yourself an<SPANCLASS="link">alias (<ACLASS="linkend"HREF="ch10_02.htm"TITLE="Aliases for Common Commands ">10.2</A>)</SPAN>,<SPANCLASS="link">shell function (<ACLASS="linkend"HREF="ch10_09.htm"TITLE="Shell Functions ">10.9</A>)</SPAN>,or<SPANCLASS="link">shell script (<ACLASS="linkend"HREF="ch44_02.htm"TITLE="Writing a Simple Shell Program ">44.2</A>)</SPAN>that executes an <EMCLASS="emphasis">stty</EM> command similar to the one below.The exact parameters you use will depend on your normal UNIX setup:</P><PCLASS="para"><BLOCKQUOTECLASS="screen"><PRECLASS="screen">stty echo -nl -cbreak</PRE

⌨️ 快捷键说明

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