blob: 827b7b6df818b7466f7ba89b8fc61bf887c07b78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
#!/usr/bin/perl
# $RCSfile: findcp,v $$Revision: 1.3 $$Date: 1999/04/29 22:51:18 $
# This is a wrapper around the find command that pretends find has a switch
# of the form -cp host:destination. It presumes your find implements -ls.
# It uses tar to do the actual copy. If your tar knows about the I switch
# you may prefer to use findtar, since this one has to do the tar in batches.
sub copy {
`tar cf - $list | rsh $desthost cd $destdir '&&' tar xBpf -`;
}
$sourcedir = $ARGV[0];
if ($sourcedir =~ /^\//) {
$ARGV[0] = '.';
unless (chdir($sourcedir)) { die "Can't find directory $sourcedir: $!"; }
}
$args = join(' ',@ARGV);
if ($args =~ s/-cp *([^ ]+)/-ls/) {
$dest = $1;
if ($dest =~ /(.*):(.*)/) {
$desthost = $1;
$destdir = $2;
}
else {
die "Malformed destination--should be host:directory";
}
}
else {
die("No destination specified");
}
open(find,"find $args |") || die "Can't run find for you: $!";
while (<find>) {
@x = split(' ');
if ($x[2] =~ /^d/) { next;}
chop($filename = $x[10]);
if (length($list) > 5000) {
do copy();
$list = '';
}
else {
$list .= ' ';
}
$list .= $filename;
}
if ($list) {
do copy();
}
|