[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Command "tail" printing of '\b' and '\t' Characters
From: |
Kevin R Frank |
Subject: |
Re: Command "tail" printing of '\b' and '\t' Characters |
Date: |
Wed, 5 Sep 2001 09:34:42 -0400 |
---------------------- Forwarded by Kevin R Frank/Raleigh/IBM on 09/05/2001
09:31 AM ---------------------------
Kevin R Frank <address@hidden> on 09/05/2001 02:18:08 PM
Please respond to Kevin R Frank address@hidden
To: Kevin R Frank/Raleigh/address@hidden
cc: Timothy Smith/Raleigh/address@hidden, GM Kump/Raleigh/address@hidden,
Kevin R
Frank/Raleigh/address@hidden, John Lloyd/Raleigh/address@hidden, Robert
Kantner/Raleigh/address@hidden, Burt Silverman/Raleigh/address@hidden,
John F
Davis/Raleigh/address@hidden, David D Smith/Raleigh/address@hidden, Truc C
Nguyen/Raleigh/address@hidden
Subject: Re: Command "tail" printing of '\b' and '\t' Characters
Hello Bob:
Thank you for the response. Here are the version strings:
mrx:/home/krfrank/tail> tail --version
tail (GNU textutils) 2.0
Written by Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering.
Copyright (C) 1999 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
mrx:/home/krfrank/tail> cat /proc/version
Linux version 2.2.14-5.0 (address@hidden) (gcc version egcs-2.91.66
19990314/Linux (egcs-1.1.2 release)) #4 Wed Dec 20 17:51:31 EST 2000
A program that reproduces the problem follows these directions.
Copy the source to a file called tail.c.
Build the program with the following command:
cc -c -Wall -O tail.c
Issue a tail on the /var/log/messages file on another tty:
tail -f /var/log/messages
Load the module into your kernel after a "switch user to root":
insmod tail.o
Remove the module with the following:
rmmod tail
The tail command will output:
tail -f /var/log/messages
Sep 5 13:51:05 mrx kernel: tail.c^H^H::init_module() line 20
Sep 5 13:51:05 mrx kernel: ^IThe back space and tab characters show up as:
Sep 5 13:51:05 mrx kernel: ^I^I- backspace -> ^H
Sep 5 13:51:05 mrx kernel: ^I^I- tab -> ^I
Sep 5 13:51:16 mrx kernel: tail.c^H^H::cleanup_module() line 34
Sep 5 13:51:16 mrx kernel: ^IUnloading...
If the output does not show up on the tail tty, do a:
ps -e -f
Issue a kill on the syslogd and klogd deamons. Then restart the deamons:
syslogd -m O
klogd
Then repeat the tail, insmod, and rmmod commands.
Thank you,
Kevin R Frank
IBM Microelectronics
address@hidden
Here is a program to reproduce the problem:
===========================================================================
#ifndef __KERNEL__
#define __KERNEL__
#endif
#ifndef MODULE
#define MODULE
#endif
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
int
init_module (
void)
{
printk(KERN_WARNING "%s\b\b::%s() line %u\n",
__FILE__, __FUNCTION__,
__LINE__);
printk(KERN_WARNING "\tThe back space and tab characters show up as:
\n");
printk(KERN_WARNING "\t\t- backspace -> ^H\n");
printk(KERN_WARNING "\t\t- tab -> ^I\n");
return (0);
}
void
cleanup_module (
void)
{
printk(KERN_WARNING "%s\b\b::%s() line %u\n",
__FILE__, __FUNCTION__,
__LINE__);
printk(KERN_WARNING "\tUnloading...\n");
return;
} /* end cleanup_module() */
MODULE_DESCRIPTION("Example Error When Using \"tail\" on Kernel Message
Log");
MODULE_SUPPORTED_DEVICE("None");
MODULE_AUTHOR("Kevin R Frank -- IBM");
===========================================================================
>
> ---------------------- Forwarded by Kevin R Frank/Raleigh/IBM on
09/05/2001
> 04:46 AM ---------------------------
>
> Bob Proulx <address@hidden> on 09/04/2001 08:06:13 PM
>
> To: Kevin R Frank/Raleigh/address@hidden
> cc: address@hidden
> Subject: Re: Command "tail" printing of '\b' and '\t' Characters
>
>
>
> Kevin
>
> > Kevin R Frank <address@hidden> on 09/04/2001 03:12:38 PM
> > Please respond to Kevin R Frank/Raleigh/address@hidden
>
> Unlikely that anyone outside of IBM would be able to use that
> address. :-)
>
> > When using the command tail <file> on a file that contain the ASCII
> > characters '\b' (i.e backspace) or '\t' (tab), we get the following
> > characters printed to the terminal rather than the expected characters:
> >
> > '\b' --> ^H
> > '\t' --> ^I
> >
> > The output tty is formated incorrectly because these characters are
> > not expanded correctly.
>
> Thanks for the report. But in the future could you provide the
> version number of the program such as provided by the 'tail --version'
> output and also the smallest possible test case to recreate the
> problem. There is not yet enough information to determine what is
> happening for you and so we can only guess.
>
> Since backspace is a control-H and tab is a control-I there is a
> relationship there. But it does not make sense that you would see
> them on your screen. Your terminal should be tracking those
> characters and operating on them. You can see the output I see.
>
> Try this experiment:
>
> echo 'abc'
> abc
> echo 'abc\b\bdef'
> adef
> echo 'abc\b\bdef' | tail
> adef
> echo 'abc\b\bdef' | cat
> adef
>
> I cannot recreate your problem using tail. I can forcibly print
> non-printing characters.
>
> echo 'abc\b\bdef' | cat -v
> abc^H^Hdef
>
> The cat -v'isible option shows that those control characters are
> there. The tail command does do character mapping. Perhaps you are
> seeing the output inside of a less/more pager or inside of an emacs
> shell terminal or perhaps in some other way that displays nonprinting
> characters in a mapped to visible manor?
>
> Bob Proulx
>
>