Jun 132012
 

This was a quick hack with some perl to chop up the logs and spit out the results I wanted.

This is not normally something I would share, but I want to be able to find it again, should I have a need for it. The first one replaces the non-printable characters and separates the transmit and receive lines to improve printed readability.

open FILE, "$ARGV[0]" or die "Couldn't open file: $!"; 
while (<FILE>){
 $string .= $_;
}
close FILE;
$string =~ s/\x1B/+/g;
$string =~ s/\x04/=/g;

@array = ( $string =~ m/../g );

$tran = "";
$rec = "";

foreach $chunk (@array) {
#print $chunk . "\n";
	if ($chunk =~ /^T/){
		$chunk =~ s/^T//;
		$tran = $tran . $chunk;
		$rec = $rec . " ";
	} 
	elsif ($chunk =~ /^R/){
		$chunk =~ s/^R//;
		$rec = $rec . $chunk;
		$tran = $tran . " ";	
	}
}

my ( $chunksize, $longtextlength ) = ( 80, length($tran) );
my @stringChunksArray = ();
my @stringChunksArray2 = ();

for( my $counter = 0; $counter< $longtextlength; $counter += $chunksize ) {
  push @stringChunksArray, substr( $tran, $counter, $chunksize );
  push @stringChunksArray2, substr( $rec, $counter, $chunksize );
}

for($i=0;$i<@stringChunksArray;$i++){
    print STDOUT $stringChunksArray2[$i]."\n";
    print STDOUT $stringChunksArray[$i]."\n\n\n";
}

The second one is specific to the rimage RAS 13 autoloader (DTP-4500) and splits on the ASCII ESC character.

Advertisement:
open FILE, "$ARGV[0]" or die "Couldn't open file: $!"; 
while (<FILE>){
 $string .= $_;
}
close FILE;
#$string =~ s/\x1B/+/g;
$string =~ s/\x04/=/g;

@array = ( $string =~ m/../g );

$tran = "";
$rec = "";

foreach $chunk (@array) {
#print $chunk . "\n";
	if ($chunk =~ /^T/){
		$chunk =~ s/^T//;
		$tran = $tran . $chunk;
#		$rec = $rec . " ";
	} 
	elsif ($chunk =~ /^R/){
		$chunk =~ s/^R//;
		$rec = $rec . $chunk;
#		$tran = $tran . " ";	
	}
}

@reclist = split(/\x1B/, $rec);
@tranlist = split(/\x1B/, $tran);

for($i=0;$i<@reclist;$i++){
    print "+" . $reclist[$i]."\t";
    print "+" . $tranlist[$i]."\n";
}

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)