Return to Snippet

Revision: 63616
at May 22, 2013 16:19 by sukantahazra


Initial Code
#!/user/bin/perl -w

use strict;
use File::Find;

my @DIRLIST = ("c:\\scratch", "c:\\sukanta\\scratch");

# Returns the SBRRES_* tables, there can be duplicate tokens
sub extract_tra_params {
	my %params = ();
	# read the input file
	open(FILE, $_) or die "Unable to open file $!";
	while(<FILE>) {
		if (/^(java.heap.size.max)=(.*)$/) {
			$params{$1} = $2;
		}
		elsif (/^(java.heap.size.initial)=(.*)$/) {
			$params{$1} = $2;
		}
		elsif (/^(tibco.deployment)=(.*)$/) {
			$params{$1} = $2;
		}
		elsif (/^(FlowLimit.*)=(.*)$/) {
			$params{$1} = $2;
		}
		elsif (/^(MaxJobs.*)=(.*)$/) {
			$params{$1} = $2;
		}
		elsif (/^(Engine.ThreadCount)=(.*)$/) {
			$params{$1} = $2;
		}
		elsif (/^(java.thread.stack.size)=(.*)$/) {
			$params{$1} = $2;
		}
		elsif (/^(Hawk.Daemon)=(.*)$/) {
			$params{$1} = $2;
		}
		else {
		}
	}
	close(FILE);
	return %params;
	# find the unique tables
}
	
sub pretty_print {
	my $key;
	my (%params) = @_;
	foreach $key (sort(keys %params)) {
		print $params{"tibco.deployment"}, "\t", $key, "\t", $params{$key}, "\n";
	}
}

#
# This function will be called for each file by the find function
#
sub process_file {
	my $fname = $_;
	my %params = ();
	if (-e $fname && !-d $fname && lc($fname) =~ /.*\.tra$/) {
		%params = extract_tra_params($fname);
		pretty_print(%params);
	}
}
find(\&process_file, @DIRLIST);

Initial URL


Initial Description
Used to extract the various config parameters from the TRA file

Initial Title
Extract TRA configuration for tra file

Initial Tags
perl

Initial Language
Perl