[comp.windows.news] extension of tee?

don@BRILLIG.UMD.EDU (Don Hopkins) (03/28/89)

I'd like a version of tee ("wy?") that instead of writing to an output
file, writes to a process. Its arguments would be the name of a
process to run and its args. It should run a shell to parse the args,
if necessary. The stuff wy reads from its stdin should be written to
its stdout, and to a pipe connected to the stdin of the process. The
process's stdout should be the same file as wy's stdout, unless the
command redirects the process's output with the shell.

Show an rwho, then the word count, all piped through more:
rwho | wy wc | more

Cat smut auditing:
alias cat "\cat \!:* | wy grep -i sex \> .dirt"

Lots of other uses. I'll leave it to your imagination. Has anybody
written something like this of general utility? Is there a simple way
to do it with the shell?

I want to use this in conjunction with a simple program called
"pshexec", which loads a PostScript program into the NeWS server
through a socket, connects stdin and stdout up to the same NeWS server
socket, then exec's a Unix program. The program can be a command line
driven program, or a shell script. The Unix process's stdout is
connected to NeWS process's stdin, whose stdout is connected back to
the Unix process's stdin. (Too bad tftp already has that port number!)
Given a pre-existing command line driven program, you can program NeWS
to interpret the Unix process's output (which could be piped through
other Unix processes, i.e. awk), and to send command lines to the Unix
process's input when you press buttons, select from menus, fill out
forms, drag things around, etc... NeWS can process all the low level
user input, and write strings of high level commands to the Unix
process's input. Or you can write a shell script on the Unix side that
reads and interprets NeWS's output, echos PostScript commands back to
NeWS, and invokes programs that output PS code.  The protocol is
totally arbitrary and application specific. NeWS could be talking to a
shell script, awk, a Lisp interpreter, a C program, a fortran program,
an nntp server, a bunch of processes piped together, image processing
filters, kermit, pearl, another NeWS server, whatever... With the
right tools, on the NeWS side and the Unix side, it would very easy to
build graphical NeWS interfaces to Unix programs, using your favorite
filters and pipes in the grand tradition of Unix, and good old command
line driven programs that work on dumb terminals, without any stinking
event dispatch loops!

Also, has anybody done anything with a remote "process server" or
"pumping station" or "socket manager"? You could run one under your
uid on every machine on the network you wanted to use, and it would
serve as your "liaison" on that machine. You'd be able to connect to
it over the network, and tell it to open files, make network
connections, listen for connections on ports, set environment
variables, fork off (and popen) unix processes, and send signals to
them, and then have it make connections between the resulting file
descriptors, and pump bytes back and forth. You should be able to
change the connections dynamically, and tell it to start and stop
pumping bytes on various channels. You should be able to ask it for
status information about the channels, like how many bytes have been
pumped, how much input is available for reading, the buffer size,
etc... You could connect to it over a control port to give commands,
but when you wanted to pump data back and forth, you just connect to
it yourself or tell it to connect to you, over another socket. One
feature I'd really like is the ability to tell it to pump bytes, until
it sees a particular regular expression in the stream, at which point it
(optionally) turns off the pump, and sends an event (i.e. writes some
string on some other socket). The event strings should undergo
re-replacement. i.e.:

When you see /^"\([^"]\), line \([0-9]+\): \(.*\)$/ on file 4,
write /(\1) \2 (\3) signal-error\n/ on file 5, and stop pumping.

Where you might be running a compile on the other end of file 4, whose
error messages look like:

"foo.c", line 47: syntax error

...And you might have a NeWS source debugger server on the other end of
file 5, whose commands look like:

(foo.c) 47 (syntax error) signal-error

...Any ideas or references or pointers to anonymous ftp directories?

	-Don