Dolda2000 GitWeb
/
utils.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Exit with correct status.
[utils.git]
/
rsc
1
#!/usr/bin/perl
2
3
if(@ARGV < 1) {
4
print STDERR "usage: rsc HOST CMD ARG...\n";
5
exit 1;
6
}
7
8
if($ARGV[0] eq "-s") {
9
$c = "";
10
while(<STDIN>) {
11
chomp;
12
s/\\(.)/$1/g;
13
$c .= $_;
14
if(/\\$/) {
15
$c =~ s/\\$/\n/;
16
next;
17
}
18
push @a, $c;
19
$c = "";
20
}
21
for (@a) {
22
exec @a;
23
print STDERR "$a[0]: $!\n";
24
exit 1;
25
}
26
} else {
27
$host = shift @ARGV;
28
$pid = open SSH, "|-";
29
if($pid == 0) {
30
exec "ssh", "$host", "rsc", "-s";
31
die "$!";
32
}
33
for (@ARGV) {
34
s/([\\\n])/\\$1/g;
35
print SSH "$_\n";
36
}
37
close SSH;
38
waitpid $pid, 0;
39
exit $?;
40
}