Posted By

sukantahazra on 05/22/13


Tagged

perl tibco tra


Versions (?)

Extract TRA configuration for tra file


 / Published in: Perl
 

Used to extract the various config parameters from the TRA file

  1. #!/user/bin/perl -w
  2.  
  3. use strict;
  4. use File::Find;
  5.  
  6. my @DIRLIST = ("c:\\scratch", "c:\\sukanta\\scratch");
  7.  
  8. # Returns the SBRRES_* tables, there can be duplicate tokens
  9. sub extract_tra_params {
  10. my %params = ();
  11. # read the input file
  12. open(FILE, $_) or die "Unable to open file $!";
  13. while(<FILE>) {
  14. if (/^(java.heap.size.max)=(.*)$/) {
  15. $params{$1} = $2;
  16. }
  17. elsif (/^(java.heap.size.initial)=(.*)$/) {
  18. $params{$1} = $2;
  19. }
  20. elsif (/^(tibco.deployment)=(.*)$/) {
  21. $params{$1} = $2;
  22. }
  23. elsif (/^(FlowLimit.*)=(.*)$/) {
  24. $params{$1} = $2;
  25. }
  26. elsif (/^(MaxJobs.*)=(.*)$/) {
  27. $params{$1} = $2;
  28. }
  29. elsif (/^(Engine.ThreadCount)=(.*)$/) {
  30. $params{$1} = $2;
  31. }
  32. elsif (/^(java.thread.stack.size)=(.*)$/) {
  33. $params{$1} = $2;
  34. }
  35. elsif (/^(Hawk.Daemon)=(.*)$/) {
  36. $params{$1} = $2;
  37. }
  38. else {
  39. }
  40. }
  41. close(FILE);
  42. return %params;
  43. # find the unique tables
  44. }
  45.  
  46. sub pretty_print {
  47. my $key;
  48. my (%params) = @_;
  49. foreach $key (sort(keys %params)) {
  50. print $params{"tibco.deployment"}, "\t", $key, "\t", $params{$key}, "\n";
  51. }
  52. }
  53.  
  54. #
  55. # This function will be called for each file by the find function
  56. #
  57. sub process_file {
  58. my $fname = $_;
  59. my %params = ();
  60. if (-e $fname && !-d $fname && lc($fname) =~ /.*\.tra$/) {
  61. %params = extract_tra_params($fname);
  62. pretty_print(%params);
  63. }
  64. }
  65. find(\&process_file, @DIRLIST);

Report this snippet  

You need to login to post a comment.