#!bin/csh -f #gb Generate Bucket #Usage:gb #The input-dir is the path that store *.pdf,*.refer,*.ps.Z,*.bib #The output-dir is the path that buckets will be constructed #Check the input if ($#argv <2) then echo "Error Input" echo "Usage:gb " echo "Execution IS Aborted" exit 1 endif echo Begin processing >log.txt date>>log.txt foreach i($1/*.pdf) #Get the bucket directory set tmp=$i:t set bucket=$tmp:r set dir=$2/$bucket echo "__________Begin to process $bucket">>log.txt echo "">>log.txt #create the Bucket directory if (! -d $dir) then mkdir $dir gunzip -c /home/dlibuser/public_html/template5.tar.gz | tar xvf - mv template5 $dir mkdir $dir/template5/reports.pkg #copy pdf, ps.Z ,refer,bib file if (! -e $1/$bucket.pdf) then echo "The pdf file doesnot exit">>log.txt else cp $1/$bucket.pdf $dir/template5/reports.pkg endif if (! -e $1/$bucket.ps.Z) then echo "The ps.Z file doesnot exit">>log.txt else cp $1/$bucket.ps.Z $dir/template5/reports.pkg endif if (! -e $1/$bucket.refer) then echo "The refer file doesnot exit">>log.txt else cp $1/$bucket.refer $dir/template5/_md.pkg endif if (! -e $1/$bucket.bib) then echo "The bib file doesnot exit">>log.txt else cp $1/$bucket.bib $dir/template5/_md.pkg endif #test the ps file compressed or no mv $1/$bucket.ps.Z $1/$bucket.ps compress $1/$bucket.ps if (! -e $1/$bucket.ps.Z) then mv $1/$bucket.ps $1/$bucket.ps.Z echo "The ps.Z file had been compressed before" else echo "*****This Bucket ps.Z file has been compressed this time">>log.txt endif chmod -R 775 $dir else echo "This Buckets has been Existed">>log.txt endif echo "**************************************" echo "**************************************" echo "The Bucket $bucket creation finish" echo "**************************************" echo "**************************************" echo "The Bucket $bucket creation finish">>log.txt echo "">>log.txt end echo End processing >>log.txt date>>log.txt