From 73610de69a3746aa4e2a6a887a58145792c3e772 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 16 Apr 2008 21:07:26 +0000 Subject: [PATCH] -Add replaycons utility to server git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1107 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server-2.0/bin/replaycons | 61 ++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 xCAT-server-2.0/bin/replaycons diff --git a/xCAT-server-2.0/bin/replaycons b/xCAT-server-2.0/bin/replaycons new file mode 100755 index 000000000..6b001ad4d --- /dev/null +++ b/xCAT-server-2.0/bin/replaycons @@ -0,0 +1,61 @@ +#!/usr/bin/perl +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html + + +use strict; + +my $file = shift; +my $bps = shift; +my $tail = shift || 0; + +if($bps eq "" || $file eq "") { + usage(); + exit(1); +} +unless ($file =~ /\//) { + $file = "/var/log/consoles/$file"; +} + +my $cps = $bps / 8; +my $ms = 1 / $cps; +my $msc = 0; +my $debug = 0; +my @c; + +select(STDOUT); +$| = 1; + +if($debug) { + print "BPS: $bps, CPS: $cps, MS: $ms\n"; +} + +if(!open(FILE,$file)) { + print "replaycon: cannot open $file\n"; + exit(1); +} + +if($tail > 0) { + seek(FILE,-$tail,2); +} + +while() { + @c = split(//); + foreach(@c) { + print $_; + $msc += $ms; + if($msc > .1) { + select(undef, undef, undef, $msc); + $msc = 0; + } + } +} + +close(FILE); + +exit(0); + +sub usage { + print "\nreplaycons: [node] [BPS] {tail}\n\n"; + print "e.g.\n\n"; + print "replaycons node5 19200\n"; +}