Bob, glad you replied. Here's what I'm trying to do.
I can connect to the webdav via the osascript. I also don't like putting usernames and passwords in flat files, seems that keychains works for that anyway.
What I'm trying to do is this. We have a Synology Diskstation at work, many of us connect to it's Shared [network] Folders via Webdav. When we're in the office we like to connect directly on the LAN for improved connectivity. When remote we use an external address.
I've created this little script which tests to see if the Synology is local and if so connects to it directly on the LAN, if it's not found then it connects from the external IP address.
echo "about to ping LOCAL"
/sbin/ping -c 1 -t 5 LOCALIP
/sbin/ping -c 1 -t 5 LOCALIP &>/dev/null
if [ $? -eq 0 ]; then
echo "About to mount to LOCAL Webdav..."
osascript -e ' mount volume "http://LOCALIP:WEBDAVPORT" '
echo "About to mount to ETERNAL Webdav..."
osascript -e ' mount volume "http://EXTERNALIP:WEBDAVPORT" '
For all practical purposes this works great. The one drawback is that when connected locally the mounted webdav has the name LOCALIP, and when connected from outside of the office the webdav mounted drive has the name EXTERNALIP (it's actually the IP address like say 192.168.0.55). I'd so love it if I could connect locally or remotely and regardless of where I'm connecting from have the same webdav name. Say maybe WEBDAV as the connected file name.
I've tried to accomplish this by mkdir a folder in the Volumes directoy and try using the mount_webdav command but I flat out couldn't get it to work.
Really appreciate any help.
SInce you are using a shell script, why not just create a symbolic link to the mounted webdav?
... rm -f /Volume/WEBDAV if [ $? -eq 0 ]; then echo echo "About to mount to LOCAL Webdav..." osascript -e ' mount volume "http://LOCALIP:WEBDAVPORT" ' ln -s /path/to/local/webdav.mount.point /Volume/WEBDAV else echo "About to mount to ETERNAL Webdav..." osascript -e ' mount volume "http://EXTERNALIP:WEBDAVPORT" ' ln -s /path/to/remote/webdav.mount.point /Volume/WEBDAV fi
Now you have a constant name at a contant location. The location could be anywhere you like, I just exampled using /Volumes/WEBDAV
If you want to actually give this your own mount point then you need to look at not using osascript and start looking at the Unix mount command. See "man mount_webdav"
mkdir -p /Volumes/WEBDAV mount -t webdav http://LOCALIP:WEBDAVPORT /Volumes/WEBDAV
However, I'm unsure if stored credentials will be used (I suspect not )
If there is a way to do this via Applescript (which is basically all the osascript was doing), I do not know it. I'm not saying a way does not exist, I'm just saying my Applescript skills stink
One other idea. Use the Unix ""mount -t webdav command once for local and once for remote. Once you have it mounted where you want it, use the Finder to create a Mac OS X "Alias". Finder -> File -> Make Alias (rename the alias as desired). This should incorporate all the connection information (I hope). You should now have a local "Alias" and a "Remote" alias. When you double click on the Alias, it should hopefully mount the webdav as it was when the Alias was created. If authenticaion is needed the Alias should handle that. NOTE: Never tried this with webdav, and never tried this with using the Unix "mount -t webdav" command. So I'm not sure it will work or not.
Message was edited by: BobHarris
This is exactly what I want to be able to do, but it doesn't work for me...
mkdir -p /Volumes/WEBDAV
mount -t webdav http://LOCALIP:WEBDAVPORT /Volumes/WEBDAV
I get no error messages, it just doesn't mount the WebDav to the share.
Update: when I run the "mount -t webdav..." line nothing happens, but if I key Up Arrow and Enter on about the 7th or 10th time it does work. WTH?