[vox-tech] Re: help with script

Ken Bloom vox-tech@lists.lugod.org
Thu, 3 Oct 2002 13:52:27 -0700


> ---ORIGINAL MESSAGE---
> Date: Thu, 3 Oct 2002 00:16:19 -0700
> To: vox-tech@lists.lugod.org
> From: Peter Jay Salzman <p@dirac.org>
> Subject: [vox-tech] help with script
> Reply-To: vox-tech@lists.lugod.org
> 
> hi lugod,
> 
> i'm allowing my students to turn in their assignments electronically
> this quarter.  they're writing C or fortran programs.  i'm requiring
> them to turn in:
> 
> 1. the program
> 2. a file showing the compile process and the program output.
> 
> for #2, i'm having them use "script".
> 
> however, script shows annoying ^M's plus any kind of backspacing and
> term codes:
> 
>    Script started on Wed Oct  2 17:00:24 2002
>    ^[]0;dhevan@jensen:~^G[dhevan@jensen dhevan]$ cc program1.c^M
>    ^[]0;dhevan@jensen:~^G[dhevan@jensen dhevan]$ exit^M
     ^^^^^^^^^^^^^^^^^^^^^^
     Judging from this sequence, it looks like the work was done in an
     xterm.

>    exit^M
> 
> some of these people hardly know how to log into a unix system, let
> alone use sed or even vi's ex commands.  i'm astounded that most of them
> use vi at all.
> 
> i can write a script that presents a shell like interface which short
> circuits this stuff saves their program output to a file, but if
> something is already written, i'd rather go that route.
> 
> any suggestions?   what does the CS department do for electronically
> submitted document?

In all of my ECS classes thus far (ECS40 and ECS110, both with Sean
Davis), the students submitted their program source code (and makefile)
electronically using `handin' (which enough other people have described
here that I don't need to), and the the professors would build our
programs themselves from our sources and run them using their own custom
shell scripts.

Students are expected to match their professors' program's output to the
point where `diff' would return no differences. The professors' shell
scripts grep through our output, looking for the essential pieces of the
correct output (however we are not told in advance what patterns they
are looking for, what input they will throw at our programs, nor what
other data they look for to find the output).

In this way, professors save time, and they know that the output is from
our binaries (and not from the sample binaries that they gave us, nor the
result of our own painstaking typing using $EDITOR).



However, there is the interesting problem of what to do with the control
codes that `script' leaves in its output. There's a good answer to this:
a) don't try to print the document on a printer.
b) don't try to run the document through less (at least not without
reading every word of the manpage and trying to finding the appropriate
combination of switches, something I don't have time to do)

Instead of either of these two strategies, open an xterm with a
sufficiently large scrollback buffer, then cat the whole file into the
xterm. Examine it in the xterm.

If anyone knows of a program that can actually parse these annoyances out
of the script output, I think that's what we're really looking for here.

Remember script is supposed to be able to do the following:

xterm1:
$mkfifo foo
$script -f foo

xterm2:
$cat foo

and as you work in xterm1, the exact same thing appears instantaneously
in xterm2. (this cool trick is documented in `man script' as the
explanation to the -f option.)

--Ken