X-Git-Url: http://dolda2000.com/gitweb/?p=utils.git;a=blobdiff_plain;f=rsc;fp=rsc;h=0e96debd235810a20f6093a90d503a5241db45d4;hp=32b2b81509197ac2207bc14440092a33e698c4ab;hb=535cc97f7ce80b29bbb5c183bb1079b44e011c6c;hpb=2c8f92ba91b645fba0456acc6dd885c4681e9e13 diff --git a/rsc b/rsc index 32b2b81..0e96deb 100755 --- a/rsc +++ b/rsc @@ -1,13 +1,20 @@ #!/usr/bin/perl +use MIME::Base64; + if(@ARGV < 1) { print STDERR "usage: rsc HOST CMD ARG...\n"; exit 1; } if($ARGV[0] eq "-s") { + if(!defined($ARGV[1])) { + print STDERR "rsc: server side needs arguments\n"; + exit 1 + } + $arg = decode_base64($ARGV[1]); $c = ""; - while() { + for (split /\n/, $arg) { chomp; s/\\(.)/$1/g; $c .= $_; @@ -25,16 +32,11 @@ if($ARGV[0] eq "-s") { } } else { $host = shift @ARGV; - $pid = open SSH, "|-"; - if($pid == 0) { - exec "ssh", "$host", "rsc", "-s"; - die "$!"; - } + $arg = ""; for (@ARGV) { s/([\\\n])/\\$1/g; - print SSH "$_\n"; + $arg .= "$_\n"; } - close SSH; - waitpid $pid, 0; - exit $?; + exec "ssh", "$host", "rsc", "-s", encode_base64($arg); + die "$!"; }