-
Notifications
You must be signed in to change notification settings - Fork 1
/
dmp-archive.r
47 lines (44 loc) · 1.65 KB
/
dmp-archive.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
archiveRule {
# dmp-archive.r
# Loop over files in a collection, *Src
# Copy all files into an archive collection. *Dest
checkCollInput (*Src);
checkCollInput (*Dest);
checkRescInput (*Res, *DestZone);
*Len = strlen(*Src);
#=============get current time, Timestamp is YYY-MM-DD.hh:mm:ss ======================
msiGetSystemTime(*TimeA, "unix");
#============ create a collection for log files if it does not exist ===============
createLogFile (*Dest, "log", "Check", *Res, *LPath, *Lfile, *L_FD);
#============ find files to archive
*Query = select DATA_NAME, DATA_CHECKSUM,COLL_NAME where COLL_NAME like '*Src%';
foreach(*Row in *Query) {
*File = *Row.DATA_NAME;
*Check = *Row.DATA_CHECKSUM;
*Coll = *Row.COLL_NAME;
*L1 = strlen(*Coll);
*Src1 = *Coll ++ "/" ++ *File;
*C1 = substr(*Coll,*Len,*L1);
if(strlen(*C1)==0) {
*DestColl = *Dest;
*Dest1 = *Dest ++ "/" ++ *File;
} else {
*DestColl = *Dest ++ *C1;
*Dest1 = *Dest ++ *C1 ++ "/" ++ *File;
}
isColl(*DestColl, *Lfile, *Status);
if (*Status >= 0) {
msiDataObjCopy(*Src1,*Dest1,"destRescName=*Res++++forceFlag=", *Status);
msiSetACL("default","own", "*Acct", *Dest1);
msiDataObjChksum(*Dest1, "forceChksum=", *Chksum);
if (*Check != *Chksum) {
writeLine("*Lfile", "Bad checksum for file *Dest1");
}
else { writeLine("*Lfile", "Moved file *Src1 to *Dest1");
writeLine("*Lfile", "Moved file *Src1 to *Dest1");
}
}
}
}
INPUT *Res=$"stage", *DestZone =$"ornlZone", *Acct =$"Mauna-acct", *Src=$"/Mauna/home/atmos/sensor", *Dest =$"/*DestZone/home/*Acct#Mauna/archive"
OUTPUT ruleExecOut