UNIX Hints & Hacks

ContentsIndex

Chapter 7: Displays and Emulations

 

Previous ChapterNext Chapter

Sections in this Chapter:

   

7.1 Terminal Types

 

7.5 Testing ASCII Terminals

 

7.8 Refreshing X

 

7.11 Control the Mouse with the Keyboard

7.2 Setting Terminal Types

 

7.6 Troubleshooting ASCII Terminals

 

7.9 Killing Resources with xkill

 

7.12 Display from a Remote X Server

7.3 Make Use of stty

 

7.7 Sharing STDIN/STDOUT on Two Terminals

 

7.10 Setting xterm Titlebars

 

7.13 ASCII Table in UNIX

7.4 Hotkeys

 

 

 

 

 

 

 

7.5 Testing ASCII Terminals

7.5.1 Description

7.5.1 Description

ASCII terminals can experience different types of emulation problems. Here are a couple of testing methods to help resolve some issues.

Example One: Checking for a Noisy Line

Flavor: BSD

Shells: All

Syntax:

yes '[string]'

Depending on how your terminal is attached and what it's attached to, it can occasionally drop characters if the line is noisy. A simple and effective test of the terminal is to fill the terminal up with characters as fast as possible. The yes command echoes a string indefinitely and performs this function well.

% yes '/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn'

When 79 characters are passed to yes, it displays the string over and over. If there are any problems with the line that the data is traveling through, some characters will drop and in some cases will not get the full 79 characters. Add spaces within the characters so that the output will have clean columns to help make the output easier to read.

/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{};abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn

If there is noise on the line you could see anything from missing characters to extraneous garbage on the screen.

/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(+   +),\ 012356789 @][<*^% AB  FGHIJKM NOPQRSTU VWXYZ :{}; abcdefijklmn
/.(+),\ 012345789 @][<->*^% ABCDE FGHIKLM NOP  QRSTU VWXYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(+???),\ 012???678 9 @][<-???^% ABCDE FGH???LM NOST?????XYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn
/.(++),\ 0123456789 @][<->*^% ABCDE FGHIJKLM NOPQRSTU VWXYZ :{}; abcdefghijklmn

If the display of all the characters is too confusing, you can always display a series of spaces and one character towards the end:

% yes '                                                      # '

You can apply 77 spaces and have a single character, the pound sign or hash mark (#), as the 78th character of the string that yes outputs. The object is to fill the entire row across the terminal with characters, so it is better to have 77 spaces than 10.

                                                            #
                                                            #
                                                            #
                                                            #
                                                            #
                                                            #

If a problem was to occur and the data wasn't coming across the line clean, you might see miscellaneous characters or a shortness of characters on some of the rows.

                                                              #
                                            ? ???             #
                                                        #
     ?? ?±                  ??<?????=????                 #
                     ???????                               #
                                                             #

Example Two: Testing by Monitoring

By executing some visual monitoring scripts and programs you can test the functionality of the emulation on your ASCII terminal. Some programs can be used to perform simple tests, such as the clear command or even the vi editor. Some third-party companies provide tools for interfacing with their applications in a non-graphical ASCII environment. These tools can also be used to run a quick test on the terminal's emulation.

There have been one or two occasions on some older flavors of UNIX in which the getty daemon would die or stop functioning due to the lack of activity between the terminal and the daemon. A workaround was discovered by creating useful activities to keep the ASCII terminal busy and the daemon running.

If you are in a situation where an ASCII terminal on your system sits idle, you might want to set up a monitoring program that acts both as a benefit to you when making your preventative maintenance rounds and as a dog-and-pony show for those (such as management) who want to see the computer appear to be doing something visually. Another solution can help keep inexperienced operators off the system if you set up a simple monitoring script: An operator could watch the screen for problems and not even have to log in to the system. This is not true for all environments, but can be used in certain situations.

An excellent tool being shipped now with most new flavors of UNIX is the process monitoring program, top. It is also available on the Internet. By using the necessary terminal emulation information, it formats system and process statistics nicely on the screen. You have to check whether top is available in your flavor. It monitors the state of the CPU, uptime, memory, and processes that run on the system. This is a great tool to have running. It does eat up some CPU time, though, so keep this in mind. Large multiprocessing servers should not have any problems running this program.

% top
9:44pm  up 81 days, 2:29, 1 user, load average: 0.12, 0.06, 0.04
40 processes: 39 sleeping, 1 running, 0 zombie, 0 stopped
CPU states:  0.0% user,  0.7% system,  0.0% nice, 99.3% idle
Mem: 47212K av, 46236K used,  976K free, 12776K shrd, 1180K buff
Swap:    0K av,    0K used,    0K free              38424K cached
USER PID PGRP %CPU PROC PRI SIZE RSS TIME COMMAND admin 28084 28084 0.73 0 60 451 201 0:00 top root 681 681 0.35 * 60 11526 870 9:19 telnetd http 16995 16991 0.14 * 60 2781 994 0:23 syslogd root 935 200 0.12 * 60 595 74 0:13 httpd root 145 0 0.06 * 60 370 53 1:17 portmap root 649 200 0.04 * 60 424 54 3:22 fam root 159 0 0.04 * 60 367 36 0:41 ypbind root 27728 200 0.03 * 60 426 75 0:00 telnetd root 3 0 0.02 * 39 0 0 4:31 automount root 169 0 0.00 * 61 0 0 0:13 nfsd root 171 0 0.00 * 61 0 0 0:12 nfsd

If top is not available, a simple script works fine to monitor the system and to provide basic emulation testing, depending on the commands you send to it. The script consists of commands that you can use to monitor the system throughout the day. You can place technical data or basic information for yourself or for someone that might be walking by. Try to use commands that test the emulation of the ASCII terminal. The monsys is a quick-and-dirty script that displays normal daily operation status and provides information as to what is happening on the system. In an endless loop, the script clears the display, executes a command, waits for five seconds, and repeats the same steps with a different command.

% vi monsys

#! /bin/sh
while [ 1 ]; do clear; echo "`hostname` - `date`"; echo; uptime; sleep 5 clear; cat /etc/motd; sleep 5 clear; df -k; sleep 5 clear; /sbin/ifconfig -a; sleep 5 clear; netstat -rn; sleep 5 clear; tail -15 /var/adm/SYSLOG; sleep 5 done

Line 1: Define the shell to use for the script.

Line 2: Begin the endless loop for displaying the information.

Line 3: Clear the screen, display the hostname, date, and uptime, and wait for five seconds.

Line 4: Clear the screen, display the messages for the day, and wait five seconds.

Line 5: Clear the screen, show the status of the filesystem, and wait five seconds.

Line 6: Clear the screen, display the current network interface settings, and wait five seconds.

Line 7: Clear the screen, display the current routing information, and wait five seconds.

Line 8: Clear the screen, output the last 20 lines of the system log file, and wait five seconds.

When the program executes, it clears the screen and waits five seconds after each command is executed. If the display scrolls for each command, you have a problem with the emulation. Here is a quick runthrough of the script:

% monsys
clear pluto - Wed Nov 4, 17:40:53 GMT 1998 5:40pm up 81 days, 2:08, 2 users, load average: 0.00, 0.01, 0.00 wait
clear Linux 2.0.33. THIS IS A RESTRICTED SYSTEM
ALL ACCESS IS BEING MONITORED
There is a SYSTEM OUTAGE tonight at 10:00pm PST For routine maintenance Have A Nice Day... wait
clear Filesystem 1024-blocks Used Available Capacity Mounted on /dev/hda1 2289010 550831 1619842 25% / /dev/hdb1 2417493 74936 2217567 3% /usr2 /dev/hdc1 2417493 116690 2175813 5% /usr3 wait
clear lo Link encap:Local Loopback inet addr:127.0.0.1 Bcast:127.255.255.255 Mask:255.0.0.0 UP BROADCAST LOOPBACK RUNNING MTU:3584 Metric:1 RX packets:10618 errors:0 dropped:0 overruns:0 TX packets:10618 errors:0 dropped:0 overruns:0
eth0 Link encap:10Mbps Ethernet HWaddr 00:60:97:56:9B:85 inet addr:209.134.46.67 Bcast:209.134.46.95 Mask:255.255.255.224 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2665861 errors:0 dropped:0 overruns:0 TX packets:2748703 errors:0 dropped:0 overruns:0 Interrupt:10 Base address:0x300 wait
clear Kernel routing table Destination Gateway Genmask Flags Metric Ref Use Iface 127.0.0.1 0.0.0.0 255.255.255.255 UH 0 0 2 lo 209.134.46.64 0.0.0.0 255.255.255.224 U 0 0 2731 eth0 0.0.0.0 209.134.46.94 0.0.0.0 UG 1 0 75770 eth0 wait
clear Nov 1 21:51:36 ugu login: setuid() failed Nov 1 21:52:17 ugu in.telnetd[14211]: connect from 199.52.34.2 Nov 1 21:54:49 ugu in.telnetd[14214]: connect from 207.115.157.108 Nov 1 21:54:51 ugu login: 2 LOGIN FAILURES FROM ppp-207-115-157-108 Nov 1 22:02:11 ugu in.telnetd[14228]: connect from 209.124.46.67 Nov 2 05:27:22 ugu in.telnetd[14442]: connect from 207.115.157.118 Nov 3 08:08:24 ugu in.telnetd[15596]: connect from 206.116.11.14 Nov 3 08:08:24 ugu telnetd[15596]: ttloop: peer died: Unknown error Nov 3 15:06:31 ugu in.pop3d[16004]: connect from 207.115.157.80 Nov 3 16:28:11 ugu in.pop3d[16042]: connect from 207.115.157.169 Nov 3 17:58:52 ugu sendmail[16088]: RAA16087: to=root, delay=00:00:00, Nov 4 13:17:11 ugu in.telnetd[16888]: connect from 206.116.11.14 Nov 4 13:17:38 ugu login: 2 LOGIN FAILURES FROM ugu.com Nov 4 14:57:48 ugu in.telnetd[17083]: connect from 206.116.11.14 Nov 4 17:39:20 ugu in.telnetd[17248]: connect from 206.116.11.14 wait

There are a couple of things to consider before running these programs and scripts on your system. Most terminals today come with screensavers, which would never be activated, resulting in characters getting burned into the display. A greater issue is one of security. If paranoia runs high in your environment, you might consider this too much of a security risk depending on how you decide to implement such a program. If you have no way to set up a secure or restricted shell account, you might want to configure the program to have its own account on the system.

vi /etc/passwd
monsys:hdJKl3J5BSIEz:8888:20: Monitor System:/tmp:/usr/local/bin/monsys

Set up the account so that the program is the shell in the /etc/passwd file. This way, if the file exits or a Ctrl+C is hit, the account logs out immediately.

Reason

Not all ASCII terminals can function as expected when the power is cycled or if they are new out of the box. Testing and monitoring their functionality is often a must.

Real World Experience

When systems and terminals are being moved on a daily basis, verifying the functionality of various ASCII terminals always takes place. You never know when a terminal's emulation will not function as it was intended to. After a system is moved into place, test it and leave monitoring tools in place to keep the terminal looking busy, if possible. This isn't only a dog-and-pony show for management and others--if the terminal resides on a NFS file server, it will appear busy with data moving across it. This is a good deterrent to keep the users off the server and not make any attempts of logging in to it.

Other Resources

Man pages:

clear, yes, top

World Wide Web:

top--ftp://ftp.groupsys.com:/pub/top/

UNIX Hints & Hacks

ContentsIndex

Chapter 7: Displays and Emulations

 

Previous ChapterNext Chapter

Sections in this Chapter:

   

7.1 Terminal Types

 

7.5 Testing ASCII Terminals

 

7.8 Refreshing X

 

7.11 Control the Mouse with the Keyboard

7.2 Setting Terminal Types

 

7.6 Troubleshooting ASCII Terminals

 

7.9 Killing Resources with xkill

 

7.12 Display from a Remote X Server

7.3 Make Use of stty

 

7.7 Sharing STDIN/STDOUT on Two Terminals

 

7.10 Setting xterm Titlebars

 

7.13 ASCII Table in UNIX

7.4 Hotkeys

 

 

 

 

 

 

 

© Copyright Macmillan USA. All rights reserved.