2
votes

I am mounting a drive on mac os using applescript.

tell application "Finder"
    try
    mount volume "http://user:[email protected]/mydrive/page.apsx/webdav"
    end try
end tell

I am getting drive name as 'webdav' and on the sidebar in shared section I am getting the server address(196.145.75.18) as drive name.

I want to change both of them as 'mydrive'.

Does anyone know how it can be done using applescript? if can not be done using applescript then is there any other way to do this?

2
BTW: 'mount volume' is a command from the 'StandardAdditions' so you don't need to tell the Finder to do the command.user3577225

2 Answers

1
votes

What you're doing is the equivalent of using the Finder's "Connect To Server..." command in the Go menu. If you use an IP address there, you're also going to see an IP address in the sidebar. There's no way to change that.

If your target server is on your LAN and has Bonjour/mdns (e.g. OS X, Windows with Bonjour Print Services or iTunes installed, or Linux with avahi-daemon installed), you can instead use "myserver.local" for an address. You can also put "local" as a search domain in your DHCP server (usually your router, but could be OS X Server for example), or manually into your network settings on your client machine(s), to just use "myserver" without ".local".

Or, if your target server is on the WAN, and you have a DNS server for mydomain.com (usually your registrar provides one, or you can host your own with, for example, OS X Server or a router firmware like DD-WRT), you can create a machine (A) record for "myserver.mydomain.com" for that IP address. In your DHCP server (typically your router, but it could be OS X Server), put "mydomain.com" in the DNS search domains; or, if it's a laptop that needs to work in multiple places, put it in manually into the network settings on your client machine(s). Then you don't have to enter the FQDN for an address when you connect, just "myserver".

0
votes

bash:

mkdir /Volumes/webdav
mount_afp http://user:[email protected]/mydrive/page.apsx/webdav /Volumes/webdav

or more likely:

sudo mkdir /Volumes/webdav
sudo mount_afp http://user:[email protected]/mydrive/page.apsx/webdav /Volumes/webdav

Case 1 in applescript:

do shell script "mkdir /Volumes/webdav"
do shell script "mount_afp http://user:[email protected]/mydrive/page.apsx/webdav /Volumes/webdav"

To use sudo in applescript, you need to create dialog box to type in password etc.