minisync/c.rb

40 lines
568 B
Ruby
Raw Normal View History

2010-09-27 13:40:21 +02:00
#!/usr/bin/env ruby
2010-09-27 15:34:24 +02:00
class IO
def readall
buf = ''
loop do
buf << begin
self.sysread 4096
rescue EOFError
return buf
end
end
end
end
class String
def shdump
"'#{gsub( /[\\']/, '\'\\\\\&\'')}'"
end
end
class File
def self.readall file
open( file) {|f| f.readall }
end
end
2010-09-27 13:40:21 +02:00
tor = IO.pipe
tos = IO.pipe
fork do
$stdin.reopen tor.first
$stdout.reopen tos.last
2010-09-27 15:34:24 +02:00
exec 'ssh', ARGV[0], 'perl', '-e', File.readall( 's.pl').shdump, ARGV[1].shdump
2010-09-27 13:40:21 +02:00
end
$stdin.reopen tos.first
$stdout.reopen tor.last
2010-09-27 15:34:24 +02:00
exec 'perl', 'r.pl', ARGV[2].shdump