Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.2 KiB

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