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.

114 lines
2.5 KiB

  1. #!/usr/bin/perl
  2. # $RCSfile: gcp,v $$Revision: 4.1 $$Date: 92/08/07 17:20:15 $
  3. # Here is a script to do global rcps. See man page.
  4. $#ARGV >= 1 || die "Not enough arguments.\n";
  5. if ($ARGV[0] eq '-r') {
  6. $rcp = 'rcp -r';
  7. shift;
  8. } else {
  9. $rcp = 'rcp';
  10. }
  11. $args = $rcp;
  12. $dest = $ARGV[$#ARGV];
  13. $SIG{'QUIT'} = 'CLEANUP';
  14. $SIG{'INT'} = 'CONT';
  15. while ($arg = shift) {
  16. if ($arg =~ /^([-a-zA-Z0-9_+]+):/) {
  17. if ($systype && $systype ne $1) {
  18. die "Can't mix system type specifers ($systype vs $1).\n";
  19. }
  20. $#ARGV < 0 || $arg !~ /:$/ || die "No source file specified.\n";
  21. $systype = $1;
  22. $args .= " $arg";
  23. } else {
  24. if ($#ARGV >= 0) {
  25. if ($arg =~ /^[\/~]/) {
  26. $arg =~ /^(.*)\// && ($dir = $1);
  27. } else {
  28. if (!$pwd) {
  29. chop($pwd = `pwd`);
  30. }
  31. $dir = $pwd;
  32. }
  33. }
  34. if ($olddir && $dir ne $olddir && $dest =~ /:$/) {
  35. $args .= " $dest$olddir; $rcp";
  36. }
  37. $olddir = $dir;
  38. $args .= " $arg";
  39. }
  40. }
  41. die "No system type specified.\n" unless $systype;
  42. $args =~ s/:$/:$olddir/;
  43. chop($thishost = `hostname`);
  44. $one_of_these = ":$systype:";
  45. if ($systype =~ s/\+/[+]/g) {
  46. $one_of_these =~ s/\+/:/g;
  47. }
  48. $one_of_these =~ s/-/:-/g;
  49. @ARGV = ();
  50. push(@ARGV,'.grem') if -f '.grem';
  51. push(@ARGV,'.ghosts') if -f '.ghosts';
  52. push(@ARGV,'/etc/ghosts');
  53. $remainder = '';
  54. line: while (<>) {
  55. s/[ \t]*\n//;
  56. if (!$_ || /^#/) {
  57. next line;
  58. }
  59. if (/^([a-zA-Z_0-9]+)=(.+)/) {
  60. $name = $1; $repl = $2;
  61. $repl =~ s/\+/:/g;
  62. $repl =~ s/-/:-/g;
  63. $one_of_these =~ s/:$name:/:$repl:/;
  64. $repl =~ s/:/:-/g;
  65. $one_of_these =~ s/:-$name:/:-$repl:/g;
  66. next line;
  67. }
  68. @gh = split(' ');
  69. $host = $gh[0];
  70. next line if $host eq $thishost; # should handle aliases too
  71. $wanted = 0;
  72. foreach $class (@gh) {
  73. $wanted++ if index($one_of_these,":$class:") >= 0;
  74. $wanted = -9999 if index($one_of_these,":-$class:") >= 0;
  75. }
  76. if ($wanted > 0) {
  77. ($cmd = $args) =~ s/[ \t]$systype:/ $host:/g;
  78. print "$cmd\n";
  79. $result = `$cmd 2>&1`;
  80. $remainder .= "$host+" if
  81. $result =~ /Connection timed out|Permission denied/;
  82. print $result;
  83. }
  84. }
  85. if ($remainder) {
  86. chop($remainder);
  87. open(grem,">.grem") || (printf stderr "Can't create .grem: $!\n");
  88. print grem 'rem=', $remainder, "\n";
  89. close(grem);
  90. print 'rem=', $remainder, "\n";
  91. }
  92. sub CLEANUP {
  93. exit;
  94. }
  95. sub CONT {
  96. print "Continuing...\n"; # Just ignore the signal that kills rcp
  97. $remainder .= "$host+";
  98. }