Package: bsdutils Version: 1:2.12r-19 Priority: wishlist Tags: patch Many times users use the 'script' program to create 'typescript' files that are latter difficult to review or reproduce. Answering comments in 400725 (release-notes: How to view logs generated by 'script'?) I developed a script that could be used to reproduce typescript files when the timing information was not properly saved.
Attached is the script, I would like you to consider its inclusion in bsdutils. I've named it 'scriptcontrol_replay'. Unlike 'scriptreplay' it does not need any timing information. Please tell me if you are going to consider it for inclusion. If so, I will write and attach a manpage for it. 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 # # This program is copyright 2004 by Javier Fernandez-Sanguino <[EMAIL PROTECTED]> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # For more information please see # http://www.gnu.org/licenses/licenses.html#GPL # 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; }
signature.asc
Description: Digital signature