Sha256: 6352c6dbf3f414c058caed148c72de007278f9f0d1ac6cd99cfa28c84887406a
Contents?: true
Size: 988 Bytes
Versions: 2
Compression:
Stored size: 988 Bytes
Contents
#!/usr/bin/env ruby require 'uri' require 'rubygems' require 'net/dav' dav_user = ENV['DAVUSER'] dav_pass = ENV['DAVPASS'] cmd = $*[0] case cmd when 'put' url = URI.parse $*[2] file = $*[1] when 'get' url = URI.parse $*[1] file = $*[2] else url = URI.parse $*[1] end res = Net::DAV.start(url) { |dav| dav.credentials(dav_user, dav_pass) if dav_user case cmd when 'put' File.open(file, "r") do |stream| dav.put(url.path, stream, File.size(file)) end when 'get' if file.nil? dav.get(url.path) do |str| $stdout.print str end else File.open(file, "w") do |stream| dav.get(url.path) do |str| stream.print str end end end when 'lsr' dav.find(url.path, :recursive => true) do |item| puts "#{item[:size]}\t#{item[:uri]}" end when 'ls' dav.find(url.path) do |item| puts "#{item[:size]}\t#{item[:uri]}" end when 'mkdir' dav.mkdir(url.path) else puts "unknown command" end }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
net_dav-0.0.2 | bin/dav |
net_dav-0.0.1 | bin/dav |