3 # $RCSfile: gcp,v $$Revision: 4.1 $$Date: 92/08/07 17:20:15 $
5 # Here is a script to do global rcps. See man page.
7 $#ARGV >= 1 || die "Not enough arguments.\n";
9 if ($ARGV[0] eq '-r') {
16 $dest = $ARGV[$#ARGV];
18 $SIG{'QUIT'} = 'CLEANUP';
21 while ($arg = shift) {
22 if ($arg =~ /^([-a-zA-Z0-9_+]+):/) {
23 if ($systype && $systype ne $1) {
24 die "Can't mix system type specifers ($systype vs $1).\n";
26 $#ARGV < 0 || $arg !~ /:$/ || die "No source file specified.\n";
31 if ($arg =~ /^[\/~]/) {
32 $arg =~ /^(.*)\// && ($dir = $1);
40 if ($olddir && $dir ne $olddir && $dest =~ /:$/) {
41 $args .= " $dest$olddir; $rcp";
48 die "No system type specified.\n" unless $systype;
50 $args =~ s/:$/:$olddir/;
52 chop($thishost = `hostname`);
54 $one_of_these = ":$systype:";
55 if ($systype =~ s/\+/[+]/g) {
56 $one_of_these =~ s/\+/:/g;
58 $one_of_these =~ s/-/:-/g;
61 push(@ARGV,'.grem') if -f '.grem';
62 push(@ARGV,'.ghosts') if -f '.ghosts';
63 push(@ARGV,'/etc/ghosts');
72 if (/^([a-zA-Z_0-9]+)=(.+)/) {
73 $name = $1; $repl = $2;
76 $one_of_these =~ s/:$name:/:$repl:/;
78 $one_of_these =~ s/:-$name:/:-$repl:/g;
83 next line if $host eq $thishost; # should handle aliases too
85 foreach $class (@gh) {
86 $wanted++ if index($one_of_these,":$class:") >= 0;
87 $wanted = -9999 if index($one_of_these,":-$class:") >= 0;
90 ($cmd = $args) =~ s/[ \t]$systype:/ $host:/g;
92 $result = `$cmd 2>&1`;
93 $remainder .= "$host+" if
94 $result =~ /Connection timed out|Permission denied/;
101 open(grem,">.grem") || (printf stderr "Can't create .grem: $!\n");
102 print grem 'rem=', $remainder, "\n";
104 print 'rem=', $remainder, "\n";
112 print "Continuing...\n"; # Just ignore the signal that kills rcp
113 $remainder .= "$host+";