Revision 10724,
1.2 KB
checked in by ghudson, 27 years ago
(diff) |
This commit was generated by cvs2svn to compensate for changes in r10723,
which included commits to RCS files with non-trunk default branches.
|
Line | |
---|
1 | #!/usr/bin/perl |
---|
2 | |
---|
3 | # $RCSfile: findcp,v $$Revision: 1.1.1.2 $$Date: 1997-11-13 01:47:43 $ |
---|
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] = '.'; |
---|
17 | unless (chdir($sourcedir)) { die "Can't find directory $sourcedir: $!"; } |
---|
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 | |
---|
35 | open(find,"find $args |") || die "Can't run find for you: $!"; |
---|
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 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.