Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/ruby
- require 'fileutils'
- def main local, remote, to="/tmp/"
- to_file = get_remote(remote, to)
- rsize = File.size(to_file)
- lsize = File.size(local)
- if rsize > lsize
- FileUtils.cp(to_file, local)
- elsif rsize == lsize
- # do nothing.
- elsif rsize < lsize
- send_remote(local, remote)
- else
- raise "must not happen"
- end
- end
- def get_remote remote, to
- to_file = File.join(to, remote.gsub(%r{/}, '_'))
- system("scp #{remote} #{to_file}")
- to_file
- end
- def send_remote local, remote
- system("scp #{local} #{remote}")
- end
- local = ARGV.shift
- remote = ARGV.shift
- main(local, remote)
Add Comment
Please, Sign In to add comment