home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


UNIX Power Tools

UNIX Power ToolsSearch this book
Previous: 42.7 termtest: Send Repeated Characters to Terminal Chapter 42
Problems with Terminals
Next: 43. Printing
 

42.8 Errors Erased Too Soon? Try These Workarounds

I just made a change to my .exrc file ( 4.9 ) . Then I started vi and noticed a message in reverse video before the screen cleared and my file was displayed. It was probably an error message. But vi , like some other programs, shows errors and then clears (erases) the screen before you can read them. Great design, eh?

Here are some workarounds:

  • When my terminal used to run at a slow data rate (1200 baud or less), I could usually read an error message before the screen cleared. In these days of 28,800 bps and above, you can still fake that. Log out. Then set your terminal or communications package to a slow data rate and log in again. Now look fast.

  • Way back, when ttys were real teletypes ( 41.2 ) , finding errors was easy: there was no screen to clear; the error was right there on the paper.

    So, if your terminal has a printer, turn it on. (On DOS, try doing [CTRL] + [PrtSC] .) Re-run your program and read the error on the paper.

  • If your window or communications program has a "capture to file" function, turn it on. Make the error happen. Turn off the capture function (important!). Then read the file - you'll probably need to use a program like cat -v ( 25.7 ) or vmore ( 25.5 ) to keep the screen-clearing characters stored in the file from erasing your screen as you read the file!

  • If you don't have a screen-capture function, but you do have the script ( 51.5 ) program, use it with the technique in the step above.

  • If your window has a scroll bar or a "page up" command, try it. Some screen-clear commands won't clear the scrolling memory.

  • Use tee ( 13.9 ) to grab the standard output and standard error to a file while you're viewing:

    
    
    |&
     
    
    
    2>&1
     
    
    % 
    
    vi foo |& tee saved_stuff
    
       
    ...csh
    
    
    $ 
    
    vi foo 2>&1 | tee saved_stuff
    
       
    ...sh
    

    Then look at the saved file with a pager program, possibly filtering it through cat -v ( 25.7 ) and/or fold ( 43.8 ) first. (The vmore script ( 25.5 ) was made for just this kind of job.)

  • Restart the program and get to the point just before the error will happen. Try to hit CTRL-s or HOLD SCREEN between the time the error is output and the screen clears. That can be tough to do over a network or on a high-speed connection, though, because of the delay between the time you press the key and the time when all the output finally stops coming.

  • Temporarily switch ( 6.10 ) to a termcap/terminfo definition that doesn't have a clear-screen capability. Two good settings for TERM are dumb and unknown .

  • That previous trick will leave your program almost useless, if it runs at all. If you do a lot of troubleshooting of full-screen programs like vi or writing startup files such as .exrc , it's worth your time to find a termcap or terminfo definition that has all the capabilities of the usual definition - except that it won't clear the screen. (You'll probably want to check the termcap capabilities cl= , is= , if= , rs= , rf= , r2= , and maybe ti= . Or, for terminfo , look at clear= , iprog= , is2= , if= , rs2= , rf= , and maybe smcup= .) If you don't know how, read O'Reilly & Associates' termcap & terminfo -or lure a UNIX guru from down the hall somewhere. [1]

    [1] Hint: all computer gurus like pizza.

- JP


Previous: 42.7 termtest: Send Repeated Characters to Terminal UNIX Power Tools Next: 43. Printing
42.7 termtest: Send Repeated Characters to Terminal Book Index 43. Printing

The UNIX CD Bookshelf Navigation The UNIX CD BookshelfUNIX Power ToolsUNIX in a NutshellLearning the vi Editorsed & awkLearning the Korn ShellLearning the UNIX Operating System