ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitProd/Processing/bin/renameSample.sh
Revision: 1.1
Committed: Thu Aug 5 03:58:20 2010 UTC (14 years, 9 months ago) by paus
Content type: application/x-sh
Branch: MAIN
CVS Tags: Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014c, Mit_014e, Mit_014d
Log Message:
This is a starting point which kind of works at MIT.

File Contents

# User Rev Content
1 paus 1.1 #!/bin/bash
2     #---------------------------------------------------------------------------------------------------
3     # Rename an existing sample (so far all potentially exisiting catalog info will have to be redone)
4     #---------------------------------------------------------------------------------------------------
5     SERVER="srm://se01.cmsaf.mit.edu:8443/srm/managerv2?SFN="
6     LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus/filefi/014"
7     #SERVER="srm://srm-cms.cern.ch:8443/srm/managerv2?SFN="
8     #LOCATION="/castor/cern.ch/user/p/paus/filefi/014"
9    
10     SOURCE="$1"
11     TARGET="$2"
12    
13     sourceExists=`srmls ${SERVER}${LOCATION} | grep $SOURCE`
14     echo " Existing - source: $sourceExists"
15     targetExists=`srmls ${SERVER}${LOCATION} | grep $TARGET`
16     echo " Existing - target: $targetExists"
17    
18     if [ ".$sourceExists" != "." ] && [ ".$targetExists" == "." ]
19     then
20    
21     #echo \
22     move ${LOCATION}/$SOURCE \
23     ${LOCATION}/$TARGET
24    
25     ##for file in `list ${SERVER}${LOCATION}/$TARGET | grep ' ' | tr -s ' ' | cut -d ' ' -f 3`
26     ##do
27     ##
28     ## file=`basename $file | cut -d '_' -f2-3`
29     ## echo \
30     ## move ${SERVER}${LOCATION}/$TARGET/${SOURCE}_$file \
31     ## ${SERVER}${LOCATION}/$TARGET/${TARGET}_$file
32     ##
33     ##done
34     fi
35    
36     cd ~/catalog/t2mit/filefi/014
37     if [ -d $SOURCE ]
38     then
39     mv $SOURCE $TARGET
40     cd $TARGET
41     ~paus/bin/repstr $SOURCE $TARGET Filesets RawFiles.??
42     fi
43    
44     cd ~/catalog/local/filefi/014
45     if [ -d $SOURCE ]
46     then
47     mv $SOURCE $TARGET
48     cd $TARGET
49     ~paus/bin/repstr $SOURCE $TARGET Filesets RawFiles.??
50     fi
51    
52    
53     exit 0
54    
55     ## MIT_LOCATION="/pnfs/cmsaf.mit.edu/t2bat/cms/store/user/paus"
56     ## CERN_LOCATION="/castor/cern.ch/user/p/paus"
57     ## CATALOG=$HOME/catalog
58     ##
59     ## # Health checks
60     ## if [ ".$1" == "." ]
61     ## then
62     ## H=`basename $0`
63     ## echo "";echo " usage: $H <version> [ <pattern> [ <location> ] ]"; echo ""
64     ## exit 1
65     ## fi
66     ##
67     ## # Decode command line parameters
68     ## VERSION="$1"
69     ## PATTERN="empty"
70     ## if [ ".$2" != "." ]
71     ## then
72     ## PATTERN=$2
73     ## fi
74     ## LOCATION=$MIT_LOCATION
75     ## if [ ".$3" != "." ]
76     ## then
77     ## LOCATION=$3
78     ## fi
79     ##
80     ## # Create a list of the datsets we need to catalog
81     ## echo ""
82     ## if [ "`echo $LOCATION | grep castor`" != "" ]
83     ## then
84     ## echo " Identified a castor sample request. Using rfdir on $LOCATION"
85     ## CATALOG=$CATALOG/cern
86     ## LIST=`rfdir $LOCATION/filler/$VERSION | tr -s ' ' | cut -d ' ' -f 9`
87     ## elif [ "`echo $LOCATION | grep cmsaf.mit.edu`" != "" ]
88     ## then
89     ## echo " Identified a tier-2 sample request. Using srmls on $LOCATION"
90     ## CATALOG=$CATALOG/t2mit
91     ## LIST=`srmls ${SERVER}${LOCATION}/filler/$VERSION | grep ' ' | tr -s ' ' | cut -d ' ' -f 3`
92     ## else
93     ## echo " Identified a local sample request. Using ls on $LOCATION"
94     ## CATALOG=$CATALOG/local
95     ## LIST=`ls -1 $LOCATION/filler/$VERSION`
96     ## fi
97     ##
98     ## # Show me the list
99     ## echo ""
100     ## echo "== LIST =="
101     ## echo $LIST
102     ##
103     ## # Loop through the list and catalog
104     ## echo ""
105     ## for dataset in $LIST; do
106     ## dataset=`basename $dataset`
107     ## if [ "$PATTERN" == "empty" ] || [ "`echo $dataset | grep $PATTERN`" != "" ]
108     ## then
109     ## ./catalogFiles.csh $LOCATION $CATALOG filler/$VERSION $dataset
110     ## fi
111     ## done