From 535cc97f7ce80b29bbb5c183bb1079b44e011c6c Mon Sep 17 00:00:00 2001 From: fredrik Date: Mon, 6 Aug 2007 04:15:08 +0000 Subject: [PATCH] Don't clobber STDIN. git-svn-id: svn+ssh://svn.dolda2000.com/srv/svn/repos/src/utils@1093 959494ce-11ee-0310-bf91-de5d638817bd --- rsc | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) 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 "$!"; } -- 2.11.0