ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/TMISoftware/ErrorStream/copyErrorFiles.pl
Revision: 1.2
Committed: Fri May 11 12:52:02 2012 UTC (12 years, 11 months ago) by fantasia
Content type: application/x-perl
Branch: MAIN
CVS Tags: V01-00-00, HEAD
Changes since 1.1: +56 -55 lines
Log Message:
indent

File Contents

# Content
1 #!/usr/bin/perl -w
2
3 if ($#ARGV != 7-1 ) {
4 print "usage: perl copyErrorFiles.pl ErrorDir FirstRun LastRun SingleRun ListFiles ListDirs User\n";
5 exit;
6 }
7
8 $ErrorDir = $ARGV[0];
9 $FirstRun = $ARGV[1];
10 $LastRun = $ARGV[2];
11 $SingleRun = $ARGV[3];
12 $ListFiles = $ARGV[4];
13 $ListDirs = $ARGV[5];
14 $User = $ARGV[6];
15
16 use Getopt::Long;
17 my $eraDir = "$ErrorDir";
18 my $firstThreeNumbers = substr($FirstRun,0,3);
19 my $lastThreeNumbers = substr($FirstRun,3,3);
20 my $runDir = "$eraDir/$firstThreeNumbers/$lastThreeNumbers";
21 if($SingleRun) {
22 if ($ListFiles) {
23 print "\nShowing error stream files from run $FirstRun : \n\n";
24 print "$runDir\n";
25 system "rfdir $runDir";
26 print "\n";
27 }
28 elsif ($ListDirs) {
29 print "\nShowing error stream directory for run $FirstRun : \n\n";
30 print "$runDir\n\n";
31 }
32 elsif (1) {
33 my $copyDir="/tmp/$User/ErrorRun_$firstThreeNumbers$lastThreeNumbers";
34 unless (-d $copyDir) {
35 system "mkdir $copyDir";
36 }
37 my $result = `tcsh -c \"source "stageDirIn.tcsh" $runDir\"`;
38 print "\n$result";
39 print "\nCopying files to $copyDir\n";
40 my @fileList = `nsls $runDir`;
41 foreach(@fileList) {
42 chomp;
43 my $thisFile = "$runDir/$_";
44 print "Copying $thisFile \n";
45 system "rfcp $thisFile $copyDir";
46
47 }
48 }
49 }
50 elsif (1) {
51 my @topList = `nsls $eraDir`;
52 my $ListF = int($ListFiles);
53 my $ListD = int($ListDirs);
54 foreach(@topList) {
55 chomp;
56 my $currentFirstThree = $_;
57 if($currentFirstThree >= $firstThreeNumbers) {
58 my @subList = `nsls $eraDir/$currentFirstThree`;
59 foreach(@subList) {
60 chomp;
61 my $currentLastThree = $_;
62 my $currentRun = $currentFirstThree.$currentLastThree;
63 last if (($LastRun != 0) && ("$LastRun" < "$currentFirstThree$currentLastThree"));
64 if($currentRun >= $FirstRun) {
65 my $currentDir = "$eraDir/$currentFirstThree/$currentLastThree";
66 if ($ListF) {
67 if ($currentRun == $FirstRun) {
68 if ($LastRun != 0) {
69 print "\nShowing error stream files from run $FirstRun to run $LastRun : \n\n";
70 }
71 elsif (1) {
72 print "\nShowing error stream files from run $FirstRun onwards: \n\n";
73 }
74 }
75 print "$currentDir/\n";
76 system "rfdir $currentDir";
77 print "\n";
78 }
79 elsif ($ListD) {
80 if ($currentRun == $FirstRun) {
81 if ($LastRun != 0) {
82 print "\nShowing error stream runs from run $FirstRun to run $LastRun : \n\n";
83 }
84 elsif (1) {
85 print "\nShowing error stream runs from run $FirstRun onwards: \n\n";
86 }
87 }
88 print "$currentRun\n";
89 }
90 elsif (1) {
91 my $copyDir="/tmp/$User/ErrorRun_$currentFirstThree$currentLastThree";
92 unless (-d $copyDir) {
93 system "mkdir $copyDir";
94 }
95 my $result = `tcsh -c \"source "stageDirIn.tcsh" $runDir\"`;
96 print "\n$result";
97 print "\nCopying files to $copyDir\n";
98 my @fileList = `nsls $currentDir`;
99 foreach(@fileList) {
100 chomp;
101 my $thisFile = "$currentDir/$_";
102 print "Copying $thisFile \n";
103 system "rfcp $thisFile $copyDir";
104 }
105 }
106 }
107 }
108 }
109 }
110 }