我需要在Ubuntu上编程地挂载WebDAV文件夹。我已经找到了使用davfs2的解决方案。
但是,在Ubuntu上,默认情况下没有安装davfs2。同时,Gnome的“地方->连接到服务器...”菜单可以在不安装davfs2的情况下完成此操作。我认为它也不需要root权限。
有什么想法可以在不安装davfs2的情况下挂载WebDAV吗?
在Ubuntu安装中已经有一个命令行工具:nd
。但是这需要每次输入用户名和密码。
如果您可以从源代码构建WebDAV客户端,例如cadaver
您可以使用--prefix
选项在configure
中选择一个您拥有写入权限的文件夹:
./configure --prefix=/home/me/cadaver/
make
make install
cadaver
支持通过 .netrc 文件自动登录需要身份验证的服务器。
Ubuntu为所有当前支持的版本提供了cadaver软件包,因此不需要编译。您可以使用命令sudo apt-get install cadaver
进行安装。正如JScoobyCed所提到的那样,“cadaver支持通过.netrc文件自动登录需要身份验证的服务器”。
以下是手册页中的一些摘录:
THE .netrc FILE
The file ~/.netrc may be used to automatically login to a server
requiring authentication. The following tokens (separated by spaces,
tabs or newlines) may be used:
machine host
Identify a remote machine host which is compared with the host‐
name given on the command line or as an argument to the open
command. Any subsequent tokens up to the end of file or the
next machine or default token are associated with this entry.
default
This is equivalent to the machine token but matches any host‐
name. Only one default token may be used and it must be after
all machine tokens.
login username
Specifies the username to use when logging in to the remote
machine.
password string
passwd string
Specifies the password to use when logging in to the remote
machine.
Any other tokens (as described in ftp(1)) are ignored.
EXAMPLES
cadaver http://dav.example.com/
Connects to the server myserver.example.com, opening the root collection.
cadaver http://zope.example.com:8022/Users/fred/
Connects to the server zope.example.com using port 8022, opening the collection "/Users/fred/".
cadaver https://secure.example.com/
Connects to a server called secure.example.com using SSL.
FILES
~/.cadaverrc
Individual user settings that can override cadaver defaults and to script cadaver. Can be changed by the "--rcfile" option.
~/.netrc
Login and initialization information used by the auto-login process. See section "THE .netrc FILE" for details.