Simple, quick and dirty synctool
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
minisync/c.rb

46 lines
787 B

#!/usr/bin/env ruby
libexec = File.expand_path File.dirname( __FILE__)
machine, source, destination = ARGV[0...3]
class IO
def readall
buf = ''
loop do
buf << begin
self.sysread 4096
rescue EOFError
return buf
end
end
end
end
class File
def self.readall file
open( file) {|f| f.readall }
end
end
class String
def shdump
"'#{gsub( /[\\']/, '\'\\\\\&\'')}'"
end
end
$tor = tor = IO.pipe
$tos = tos = IO.pipe
Process.fork do
$stdin.reopen tor.first
tor.last.close
$stdout.reopen tos.last
tos.first.close
exec 'ssh', machine, 'perl', '-e', File.readall( File.join( libexec, 's.pl')).shdump, source.shdump
end
$stdin.reopen tos.first
tos.last.close
$stdout.reopen tor.last
tor.first.close
exec 'perl', File.join( libexec, 'r.pl'), destination