view archivemany.sh @ 35:e27d097a9d87

still issues with "while read"
author casties
date Fri, 23 Jun 2006 11:40:12 +0200
parents 8b9d91963de7
children 1afdf186b65e
line wrap: on
line source

#!/bin/bash

VERSION="archivemany V0.2 (23.9.2005 ROC)"

#set -x

if [ -z "$1$2" ]
then
    echo $VERSION
    echo "use: $0 docdir dirlist"
    echo "  Archives the directories given in the file dirlist inside docdir."
    exit 1
fi

BASEDIR="$1"
DIRLIST="$2"
PARAM1="$3"
PARAM2="$4"
PARAM3="$5"
CNT="1"

if [ ! -d $BASEDIR ]
then
    echo "ERROR: base directory $BASEDIR not found!"
    exit 1
fi

if [ ! -f $DIRLIST ]
then
    echo "ERROR: directory list file $DIRLIST not found!"
    exit 1
fi

cat $DIRLIST | while read DIR
do
    if [ -d "$BASEDIR/$DIR" ]
    then
	echo "archiving document $CNT: $DIR..."
	if /usr/local/mpiwg/archive/archiver "$PARAM1" "$PARAM2" "$PARAM3" "$BASEDIR/$DIR"
	then
	    echo "  done on `date`"
	else
	    echo "FAILED!"
	    # abort?
	fi
    else
	echo "ERROR: document directory $BASEDIR/$DIR not found!"
    fi
    CNT=$(( $CNT + 1 ))
done