How to mount/unmount webdav server directory using Terminal

1

I use OS X 10.10.1 and I want to mount a HTTPS webdav server directory as a volume on my local machine using Terminal.

I found this utility -- mount_webdav -- which seems to work - I created a mountpoint /Volumes/mpt and was able to mount it, but I am unable to see the volume and unmount it.

I used the -v switch to set a volume name 'files' when mounting, expecting to see the volume listed as /Volumes/mpt/files but this does not happen - there is no such volume, although the contents of the server directory appear in /Volumes/mpt.

I don't quite understand this. If the volume doesn't appear how can I unmount it?

ramius

Posted 2014-12-26T19:58:29.397

Reputation: 158

Answers

2

Command line mounting and Finder never play nicely with each other. A simpler way that leverages all the backend stuff that Finder does is to simply use the open command. i.e.

open smb://server/mountpoint/

But that doesn't work well with WebDAV servers, as open will send all http/https links to the default browser by default.

Another way is to use an Applescript to tell Finder to mount the drive. You can save the script as an app, which you can then call from the open command or via the GUI, and it will let Finder handle the mount just as it would if you used Cmd-K. Or you could always just use it inside an osascript call from the terminal, via an alias or traditional bash script. As an example:

tell application "Finder"
    try
        mount volume "https://user@server.domain.tld/mountpoint"
    end try
end tell

I have a "MountDrives.app" script/app that has lived in my /Applications directory for years now; It runs at startup and lets me quickly re-mount heavily used shares quickly and easily.

peelman

Posted 2014-12-26T19:58:29.397

Reputation: 4 580

1

Thanks @peelman but I am well aware that you can use Finder to open WebDAV directories (not recommended by the organisation's recommended guidelines for accessing the WebDAV directory in question) and I know how to write Applescripts. That wasn't my question.

My question was specifically about using mount_webdav to mount WebDAV directories from Terminal, and why it did not work as expected. It was also about understanding the low-level details of how this works on OS X.

– ramius – 2014-12-27T04:11:21.193

1Then your question did a poor job conveying what knowledge you sought. – peelman – 2014-12-29T12:39:42.083

You didn't read my question, which was a perfectly clear and reasonable one about using the mount_webdav command line utility to mount/unmount WebDAV directories, not about a "way that leverages all the backend stuff" using Applescripts or some GUI. If you can't answer it fine, but it is poor form to attack a questioner when they point out that a purported answer is not actually an answer to their question.

– ramius – 2014-12-29T12:50:55.190

@ramius You did not mention that you know about Finder and you are not allowed to use it. If you have special needs and are not allowed to use certain alternative solutions to a problem you need to mention this.

Otherwise those who attempt to answer will assume that you do not know about the alternative solutions and will present it to you. – Martin – 2017-01-30T07:22:01.723