comparison archivemany.sh @ 37:1afdf186b65e

added error message for empty list file
author casties
date Fri, 23 Jun 2006 11:58:17 +0200
parents 8b9d91963de7
children
comparison
equal deleted inserted replaced
36:9eb746dc69f8 37:1afdf186b65e
1 #!/bin/bash 1 #!/bin/bash
2 2
3 VERSION="archivemany V0.2 (23.9.2005 ROC)" 3 VERSION="archivemany V0.3 (23.6.2006 ROC)"
4 4
5 #set -x 5 #set -x
6 6
7 if [ -z "$1$2" ] 7 if [ -z "$1$2" ]
8 then 8 then
9 echo $VERSION 9 echo $VERSION
10 echo "use: $0 docdir dirlist" 10 echo "use: $0 docdir dirlist [params...]"
11 echo " Archives the directories given in the file dirlist inside docdir." 11 echo " Archives the directories given in the file dirlist inside docdir."
12 exit 1 12 exit 1
13 fi 13 fi
14 14
15 BASEDIR="$1" 15 BASEDIR="$1"
16 DIRLIST="$2" 16 DIRLIST="$2"
17 PARAM1="$3" 17 PARAM1="$3"
18 PARAM2="$4" 18 PARAM2="$4"
19 PARAM3="$5" 19 PARAM3="$5"
20 CNT="1"
21 20
22 if [ ! -d $BASEDIR ] 21 if [ ! -d $BASEDIR ]
23 then 22 then
24 echo "ERROR: base directory $BASEDIR not found!" 23 echo "ERROR: base directory $BASEDIR not found!"
25 exit 1 24 exit 1
29 then 28 then
30 echo "ERROR: directory list file $DIRLIST not found!" 29 echo "ERROR: directory list file $DIRLIST not found!"
31 exit 1 30 exit 1
32 fi 31 fi
33 32
34 cat $DIRLIST | while read DIR 33 CNT=0
34
35 # read directories from DIRLIST
36 while read DIR
35 do 37 do
38 CNT=$(( $CNT + 1 ))
36 if [ -d "$BASEDIR/$DIR" ] 39 if [ -d "$BASEDIR/$DIR" ]
37 then 40 then
38 echo "archiving document $CNT: $DIR..." 41 echo "archiving document $CNT: $DIR..."
39 if /usr/local/mpiwg/archive/archiver "$PARAM1" "$PARAM2" "$PARAM3" "$BASEDIR/$DIR" 42 if /usr/local/mpiwg/archive/archiver "$PARAM1" "$PARAM2" "$PARAM3" "$BASEDIR/$DIR"
40 then 43 then
42 else 45 else
43 echo "FAILED!" 46 echo "FAILED!"
44 # abort? 47 # abort?
45 fi 48 fi
46 else 49 else
47 echo "ERROR: document directory $BASEDIR/$DIR not found!" 50 echo "$CNT ERROR: document directory $BASEDIR/$DIR not found!"
48 fi 51 fi
49 CNT=$(( $CNT + 1 )) 52 done < $DIRLIST
50 done 53
54 if [ $CNT = 0 ]
55 then
56 echo "ERROR: the list file $DIRLIST seems to be empty!"
57 fi