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

Bug#400725: release-notes: How to view logs generated by 'script'?



On Tue, Nov 28, 2006 at 11:01:54AM +0100, Jan Wagner wrote:
> Package: release-notes
> Severity: normal
> 
> http://www.debian.org/releases/etch/i386/release-notes/ch-upgrading.en.html#s-upgradingpackages 
> recommands to use 'script' and less 
> to view the log. Unfortunately with less I have many control chars wich makes 
> it a bit difficult to work with. 'more' seems to work 
> more proper.

If you have used 'script' with a timing parameter you can use 'scriptreplay'.
If you have not, you can just generate the timing file from scratch (use 1
millisecond timers per char) so that you can replay it later. I wrote a long
time ago a utility that would do this automatically for you, it was just a
simple Perl script that would read the typescript and replay (char by char)
the contents with 1 millisec delay. 

[ few minutes later ]

Attached is a first attempt at such a Perl script, you can even control the speed of the output (using '+' or '-'). Feel free to modify as needed.

Regards

Javier
#!/usr/bin/perl -w
# Reproduce a typescript file (generated by script(1)) line by line.
# with a controlling terminal
# Keys:
# - - increase timestep 10ms (i.e output slower)
# + - decrease timestep 10ms (i.e. output faster)
# q - quit reading the file

use Term::ReadKey;

my $readfiles=0;


ReadMode 4;
# Set signal trappers to reset terminal
$SIG{INT} = \&catch_zap;
$SIG{QUIT} = \&catch_zap;
$SIG{KILL} = \&catch_zap;
$SIG{TERM} = \&catch_zap;

foreach $file (@ARGV) {
    $readfiles++;
    printout($file);
}

ReadMode 0; # Reset tty mode before exiting

if ( $readfiles == 0 ) {
    print STDERR "USAGE: replay_typescript file1 file2 ...\n";
    exit 1;
}

exit 0;

sub catch_zap {
    my $signame = shift;
    ReadMode 0; # Reset tty mode before exiting
    die;
}

sub printout {
    my ($file) = $file;
    my $time = 0.10;
    my $key;
    open (FILE, "<$file") || die "Cannot open file: $file: $!";
    while (<FILE>) {
        print $_;
        select(undef, undef, undef, $time); # Wait several ms
        $key = ReadKey(0.10);
        if ( defined ($key) ) {
            $time = $time - 0.10 if ($key eq "+") ; # Faster!
            $time = $time + 0.10 if ($key eq "-") ; # Slower!
            last if ($key eq "q") ; # Quit!
            $time = 0 if $time < 0 ;
        }
    }
    close FILE;
}

Attachment: signature.asc
Description: Digital signature


Reply to: