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