DavClient

DESCRIPTION:

A scriptable WebDAV command line client for Ruby for managing content on webservers that support the WebDAV extensions.

This is still very much work in progress. Especially the command line interface is changed a lot recently. The ruby library however is starting to settle.

Requirements

The command line utility curl installed and available in your unix path.

LIRBRARY SYNOPSIS:

require 'rubygems'
require 'davclient'

# Print url of all files in webdav folder recursively
# with basic tree walking

url = 'http://test.webdav.org/dav/'
WebDAV.find(url, :recursive => true) do |item|
  puts item.href
end

COMMAND LINE UTILITIES:

DavClient includes the command line utility ‘dav’. It is inspired by git and should be familiar to unix users. The command ‘dav cd url’ sets current working url, ‘dav ls’ list files and ‘dav pwd’ prints current working url. , users can access files, folders and their properties on webdav servers.

The only authentication method supported at the moment, is by reading usernames and passwords from a file named ~/.netrc. If username is missing, the ‘dav’ command will print out detailed instructions on how to add username etc. to the ‘~/.netrc’ file.

COMMAND LINE SYNOPSIS:

bash $ dav cd http://test.webdav.org/dav/
http://test.webdav.org/dav/
bash $ dav ls
images/
index.html
bash $ dav pwd
http://test.webdav.org/dav/
bash $ get ./index.html
bash $ dav --help
usage: dav COMMAND [ARGS]

Available dav commands:
   ls        List files on webdav server
   pwd       Print current working url
   cd        Change current working url
   cp        Copy resource
   mv        Move resource
   rm        Remove resource
   cat       Print content of resource
   mkdir     Create remote collection (directory) (mkcol alias)
   get       Download resource
   put       Upload local file
   propfind  Print webdav properties for url
   mkcol     Make collection
   options   Display webservers WebDAV options
   edit      Edit contents of remote file with editor

USE WITH IRB:

IRB can also be used as an interactive dav console:

bash $ irb -rubygems -rdavclient/simple
>> cd "https://webdav.org/projects/"
=> "https://webdav.org/projects/"
>> pwd
=> "https://webdav.org/projects/"
>> content = get "index.html"
=> "index.html"
>> ls
index.html
>> cd ".."
=> "https://webdav.org/"

INSTALL:

If you can type the command ‘curl’ in your terminal window, everything is ok.

DavClient uses the command line utility cURL to interact with servers. Curl comes preinstalled on Mac OS X. It can also be downloaded from curl.haxx.se/ . If you are using debian or ubuntu, it can be installed with apt-get:

sudo apt-get install curl

Then install DavClient:

[sudo] gem install davclient

or

git clone git://github.com/thomasfl/davclient.git
cd davclient
sudo rake install

Background:

There has been posted a few examples on the web of how to make a WebDAV client. The problem is that they all seem to support only one type of username and password authentication. DavClient instead uses the command line tool ‘curl’ to do all the authentication and networking. To avoid handling authentication all togheter, curl are told to look up all usernames and passwords are in a file named ~/.netrc.

The command line utility ‘dav’ is non-interactive and inspired by git, making it more suitable for use in scripts. If you can script in Ruby, the examples folder includes sample scripts using the davclient Ruby library.

Licence

DavClient (davclient and the dav utility) is copyrighted free software by Thomas Flemming <thomas dot flemming at usit.uio.no> and contributors. You can redistribute it and/or modify it under either the terms of the GPL2 or the conditions below:

See LICENCE file for details.

Comments

Feel free to contact me at thomas dot flemming at usit.uio.no.