#!/usr/bin/perl

#
# Script: acopy, a version of cp for AFS
# Author: Francisco Lozano - Cern (21-May-96)
#

require 'getopts.pl';   # Subroutines: Getopts.

&Usage if !&Getopts ('vh:');
&Usage if !defined($ARGV[1]);
&Usage if $opt_h;

$cwd = $ENV{'PWD'};
$prefix = ($ARGV[1] =~ /^\// ? "" : $cwd."/"); 
    
die "Can't cd to $ARGV[0]: $!\n" unless chdir $ARGV[0];


foreach $n ("/usr/bin/afind", "/bin/afind", "/usr/local/bin/afind" ) {
    if (-x $n) {
	print "$n -t d -e \"/usr/bin/up -1 ./{} $prefix$ARGV[1]/{}\""."\n"
	    if $opt_v;
        `$n -t d -e "/usr/bin/up -1 ./{} $prefix$ARGV[1]/{}"`;
	chdir $cwd;
	exit;
    }
}

sub Usage {
    print STDERR "Usage: acopy [-v] [-h(elp)] <source dir> <destination dir>\n";
    exit -1;
}
