[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Removing VT220 control characters with GAWK

From: Bob Proulx
Subject: Re: Removing VT220 control characters with GAWK
Date: Thu, 17 Apr 2008 13:35:43 -0600
User-agent: Mutt/1.5.13 (2006-08-11)

Dylan VanHerpen wrote:
> Bob Proulx wrote:
> > I am sure that awk can do this because it is very general purpose.
> > But 'col' will also do this out-of-the-box.  You might want to try
> > 'col -b' which is the common idiom that I typically use.
> I tried col, but it doesn't leave a field separator. I did have better
> luck with tr, which does a good job removing ESC: tr [:cntrl:] ,

I would probably stick with awk or sed.  IIRC awk has been ahead in
speed over sed and if you are worried about performance then I would
try to do it all your, already present, awk script.

> However, I'm trying to clean up the capture in real-time, and return the
> results to a voice application. I'm concerned that the sequence of
> running the data through tr first, and then awk will slow things down a
> bit.

You might try to do everything in expect's tcl regex engine.
Depending upon many factors it may be faster because you avoid another
process.  Or it may also be slower because you lose the multi-process
if on a multi-processor system.  Or, or, or...  You would have to try
it and see.

> > Alternatively if you can avoid generating the terminal escape
> > sequences in the first place then they wouldn't need to be removed.
> > In most cases setting TERM=dumb will avoid this problem at the start.
> That sounds like a great idea. I'll try that first.

I like taking work out of the system.  :-)

> > It all depends on your application and why you are using expect in
> > the first place.
> It seemed like the right tool for the job. Here's what I'm doing:
> I collect the data from a telnet session to an Avaya PBX, using VT220
> emulation. The data is screen-formatted, not list formatted, and the
> resulting capture is pretty messy. What would you recommend instead of
> Expect?

I wasn't commenting upon expect.  I was commenting upon the
application that was being wrapped by expect.  Expect is great for
things that need to emulate interactivity such as logins with
passwords, programs that unconditionally use terminal emulation, or
anything that requires a tty device.  In this case your use for the
PBX seems reasonable to me.  I would probably use expect or one of the
derivatives (such as the expect library for ruby.)

My comment about using TERM=dumb probably doesn't apply here then.  If
you are telnet'ing to the PBX interface it probably doesn't have a way
to set the TERM.  I don't know because I have never talked to an Avaya
PBX before and have no idea of its capabilities.  (To be clear I
wasn't suggesting that setting TERM on the client end would affect the
behavior on the server end.  But if it were a remote shell then
setting it on the remote end would quiet down editors and applications
like that on the remote end.)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]