[net.unix-wizards] Shell Filter

dat@AMES-NAS.ARPA (David A. Tristram) (10/02/85)

>     I am trying to write a filter for the shell.  The  idea
>is  to  trap  commands  and carry out certain actions before
>passing a possibly modified command on to the  shell.   This
>seemingly simple task is proving rather difficult.

Your idea for using ptty's seems sound.  I have done much the same
using named pipes on sysV.  For the filter, I would try it using m4,
or awk if your processing is complicated.  There are only a couple
cases where you would have to turn off pre-processing to send raw
data to a program, such as a hereis (<<) document or quoted strings.
In awk, you could implement that by setting a flag when those
structures are encountered.

Tristram

----------



------- End of Forwarded Message

----------

cottrell@NBS-VMS.ARPA (COTTRELL, JAMES) (10/16/85)

/*
> >     I am trying to write a filter for the shell.  The  idea
> >is  to  trap  commands  and carry out certain actions before
> >passing a possibly modified command on to the  shell.   This
> >seemingly simple task is proving rather difficult.
> 
> Your idea for using ptty's seems sound.  I have done much the same
> using named pipes on sysV.  For the filter, I would try it using m4,
> or awk if your processing is complicated.  There are only a couple
> cases where you would have to turn off pre-processing to send raw
> data to a program, such as a hereis (<<) document or quoted strings.
> In awk, you could implement that by setting a flag when those
> structures are encountered.

Try hacking on script. We have a terminal here that xmt's upper
case when unshifted, lower case when shifted. You heard me right.
The first thing I did was flip the case on all incoming alfa's.
The damn thing also uses ^Z for backspace instead of ^H, which is
hardwired into the tty driver, so I change ^H to ^Z. But wait!
Cursor addressing is ^C, Y, X, where X & Y are unbiased! So I have
to have a state machine allowing the next two chars literally.
There's more. It seems that stty nl[1-3] cr[1-3] don't send
nulls, so I have to do my own padding. Etcetera...

There is no reason why you couldn't do history or anything else
you wanted to do here as well.

My own question: I would like to put my VT220 to work in VT220 mode
instead of running it in VT100 mode. Unfortunately it believes in
the parity bit & goes into weird character set mode. Is there any
way to force the parity bit always off under BSD4.2? If not, I'll
have to hack script again.....

	jim		cottrell@nbs
*/
------

dv@well.UUCP (David W. Vezie) (10/19/85)

On the subject of Shell Filters, I've thought of writing a program
called "emulate" that would start up a shell as any terminal you
desired.  It would read in data, interpret that as if it were for
that kind of terminal, figure out how to do that with your terminal,
and do it to your terminal.  It would also figure out (somehow) about
function keys.  The nice thing about it would be in case you had some
terminal depndent code, and wanted to be able to use it on a different
terminal.  Has anyone heard of such a beast (I've never been into
re-inventing the wheel (That was my great^n grandfather's claim to fame!)).


			David W. Vezie

			{dual|hplabs}!well!dv

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (10/20/85)

Well, really you shouldn't HAVE any terminal-dependent code.
That's what termcap/terminfo is all about!

(Actually, beasties like the 5620 necessarily use
terminal-dependent code, but your emulation is VERY
unlikely to be able to emulate these on other terminals.)