-#!/bin/perl
+#! /usr/bin/perl
-# $Header: gsh,v 2.0 88/06/05 00:17:20 root Exp $
+# $RCSfile: gsh,v $$Revision: 4.1 $$Date: 92/08/07 17:20:20 $
# Do rsh globally--see man page
sub getswitches {
while ($ARGV[0] =~ /^-/) { # parse switches
- $ARGV[0] =~ /^-h/ && ($showhost++,$silent++,shift,next);
- $ARGV[0] =~ /^-s/ && ($silent++,shift,next);
- $ARGV[0] =~ /^-d/ && ($dodist++,shift,next);
- $ARGV[0] =~ /^-n/ && ($n=' -n',shift,next);
- $ARGV[0] =~ /^-l/ && ($l=' -l ' . $ARGV[1],shift,shift,next);
+ $ARGV[0] =~ /^-h/ && ($showhost++,$silent++,shift(@ARGV),next);
+ $ARGV[0] =~ /^-s/ && ($silent++,shift(@ARGV),next);
+ $ARGV[0] =~ /^-d/ && ($dodist++,shift(@ARGV),next);
+ $ARGV[0] =~ /^-n/ && ($n=' -n',shift(@ARGV),next);
+ $ARGV[0] =~ /^-l/ && ($l=' -l ' . $ARGV[1],shift(@ARGV),shift(@ARGV),
+ next);
last;
}
}
if ($wanted > 0) {
print "rsh $host$l$n '$cmd'\n" unless $silent;
$SIG{'INT'} = 'DEFAULT';
- if (open(pipe,"rsh $host$l$n '$cmd'$dist 2>&1|")) { # start an rsh
+ if (open(PIPE,"rsh $host$l$n '$cmd'$dist 2>&1|")) { # start an rsh
$SIG{'INT'} = 'cont';
- for ($iter=0; <pipe>; $iter++) {
+ for ($iter=0; <PIPE>; $iter++) {
unless ($iter) {
$remainder .= "$host+"
if /Connection timed out|Permission denied/;
}
print $showhost,$_;
}
- close(pipe);
+ close(PIPE);
} else {
+ print "(Can't execute rsh: $!)\n";
$SIG{'INT'} = 'cont';
- print "(Can't execute rsh.)\n";
}
}
}
if ($remainder) {
chop($remainder);
- open(grem,">.grem") || (printf stderr "Can't make a .grem file\n");
+ open(grem,">.grem") || (printf stderr "Can't make a .grem file: $!\n");
print grem 'rem=', $remainder, "\n";
close(grem);
print 'rem=', $remainder, "\n";