I really, really hate pointing and clicking.
I distribute files to my students via Rutgers’s relatively benign though sometimes clunky “learning management system,” Sakai. One of the nice features of Sakai is that it will let you connect to the “Resources” section of a Sakai course site as a file server. One of the less-nice-features is that the connection protocol is WebDAV. Nonetheless, for a while now the macOS Finder has had reasonable support for mounting WebDAV servers as drives. Better yet, this support can be accessed from the command line, via AppleScript. It seems likely that Apple will eventually trash AppleScript as part of their general campaign to iOSify the Mac, but until that act of vandalism is complete, the Finder’s
mount verb works.
Before macOS Sierra, all one had to do was
tell application "Finder" try mount volume https://sakai.rutgers.edu/dav/ENDPOINT end try end tell
ENDPOINT was whatever endpoint Sakai told me to use. Then the Sakai site Resources are mounted at
/Volumes/ENDPOINT and can be (slowly) manipulated from the command line like any other directory. (And unmounted with
umount.) The other trick is that macOS files should be copied to WebDAV with
cp -X file /Volumes/ENDPOINT; plain
cp file /Volumes/ENDPOINT ends up leaving two files visible in Sakai Resources,
._file (resource forks live on!). It is still, so far as I can tell, impossible to manipulate DAV properties outside of the web interface, so you can’t change permissions or display names or anything like that. Still, moving files programmatically dispenses with a satisfying number of mouse gestures.
This still sort of works in Sierra, but it glitchily produces an empty folder at
/Volumes/ENDPOINT (readable only by root) while mounting the WebDAV server at
/Volumes/ENDPOINT-1. Googling yielded a solution, which is to include the WebDAV username in the URL:
tell application "Finder" try mount volume https://NETID@sakai.rutgers.edu/dav/ENDPOINT end try end tell
I wrap this up into something the shell can run as follows:
#!/usr/bin/osascript -- Usage: davmount <url> property usage_string : "Usage: davmount <url>" on run argv if (count of argv) is not equal to 1 then return usage_string end if set arg to item 1 of argv tell application "Finder" try mount volume arg end try end tell end run