From df4993908ecc42e64d585f34cb95d58ad2d07798 Mon Sep 17 00:00:00 2001 From: fredrik Date: Mon, 6 Aug 2007 01:19:14 +0000 Subject: [PATCH] Checked in rsc. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1090 959494ce-11ee-0310-bf91-de5d638817bd --- rsc | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 rsc diff --git a/rsc b/rsc new file mode 100755 index 0000000..a84668d --- /dev/null +++ b/rsc @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +if(@ARGV < 1) { + print STDERR "usage: rsc HOST CMD ARG...\n"; + exit 1; +} + +if($ARGV[0] eq "-s") { + $c = ""; + while() { + chomp; + s/\\(.)/$1/g; + $c .= $_; + if(/\\$/) { + $c =~ s/\\$/\n/; + next; + } + push @a, $c; + $c = ""; + } + for (@a) { + exec @a; + print STDERR "$a[0]: $!\n"; + exit 1; + } +} else { + $host = shift @ARGV; + $pid = open SSH, "|-"; + if($pid == 0) { + exec "ssh", "$host", "rsc", "-s"; + die "$!"; + } + for (@ARGV) { + s/([\\\n])/\\$1/g; + print SSH "$_\n"; + } + close SSH; + waitpid $pid, 0; +} + + -- 2.11.0