khaworth - Jan 11, 2008 - 12:39 pm
I am interested in having my computer automatically connect to a server and mount a particular volume every day at a certain time (so that a backup can run). I found the following ticket very useful.
http://macosx.com/tech-support/mac/s...es/334621.html
If I am already connected to one volume on the server of interest (by having typed apple-k and connecting) then the automator workflow works perfectly and will connect to all of the other volumes of interest. However if I am not yet connected, the work flow runs and says it was succesful even though it does not mount the volumes (i.e. they don't show up in finder).
What do I need to do so that it will connect for me, or at least bring up a screen asking for the Registered User Name and password?
Thanks!
khaworth - Jan 13, 2008 - 1:28 pm
I saw that this ticket is set to expire on Monday. However it would still be useful after that date to have an answer, so if it is possible to move the expiration date back, I'd appreciate it!
macbri - Jan 16, 2008 - 6:13 am
Hi Kevin -
Are you running OS X Tiger (10.4.x) or Leopard (10.5.x)? I have tested it out here on Tiger and it seems to work, so if I can duplicate your setup it might help reproduce the problem. I should also note I tested this with SMB but if you have a different server setup (AFP, NFS or whatever) perhaps the results are different.
So let me know what your setup is and I'll see what we can do to help!
- Brian
khaworth - Jan 17, 2008 - 6:05 am
Hi Brian,
I am running Tiger (10.4.11) and the machine I am connecting to is running the server version of Tiger. When I connect using using apple-K it is an AFP connection. The process I go through when I connect manually is to hit apple-K. Then in the server address box I type the IP address (ie something like XXX.XXX.XXX.XXX) and click connect. The IP address is a static IP address that is not behind a home router (so it's not a 192.168.XXX.XXX or 10.0.0.X) but is the static IP address assigned to this computer at my research lab (we don't have an IT guy to help me out on this either). Assuming I haven't connected before, then after clicking connect, I'll see a window come up that comes up that says "Connecting to afp://XXX.XXX.XXX.XXX". Then after a second or two the diaglouge box comes up saying "Connect to the file server "Computer Name." and this is where I choose to connect as a registered user (using my account on that computer). I type in my user name and password for the computer (which is automatically filled in because I have selected the button to remember it in keychain) and then I click connect. Following this, I am then given a dialouge box which shows all the different volumes I can mount on the server (we have 2 different back up volumes, a few different volumes for other things like a joint 'public' account, a volume where software is stored, my own account on the computer, etc.). I select the ones I want and those volumes are mounted.
If I've already gone through the process to connect and mount at least one volume, then to connect and mount to another volume I do the same process, except it doesn't ask me for my username and password after hitting apple-k and typing in the IP address, it just takes me directly to the dialogue box to select the volumes to mount.
As I mentioned before my workflow in automator (which consists of) will connect to and mount a volume if I have already previously connected to and mounted at least one volume on the computer. However it will not work if I have not yet connected to and mounted any volumes.
My automator work flow is very simple:
1) Get Specified Server: I have tried just afp://XXX.XXX.XXX.XXX
and I have tried listing the specific volumes such as:
afp://XXX.XXX.XXX.XXX/volumeA
afp://XXX.XXX.XXX.XXX/volumeB
The later approach making more sense, but when that didn't bring up a dialogue box to put in a user name and password (and didn't work) then I thought maybe the first way would, but it also did not bring up a dialogue box for my username and password (or work). If I have already mounted at least one volume on the computer, then when I run the workflow using afp://XXX.XXX.XXX.XXX it does bring up the dialogue box to select which volume I want to mount, which I select and then it successfully mounts. If I have already mounted at least one volume on the computer, then when I run the workflow using afp://XXX.XXX.XXX.XXX/volumeA it does not bring up the dialogue box to select a volume, it just connects and mounts volumeA. If have not yet mounted at least one volume on that computer then in both cases (afp://XXX.XXX.XXX.XXX or af[://XXX.XXX.XXX.XXX/volumeA) it runs through the work flow, says it was successfully run but no dialogue boxes appear at any time and no volumes are mounted.
2) Connect to Servers
That's the end of the work flow. If I run it in Automator, it always shows a little green check mark in each box of the work flow after running, whether or not it has connected and mounted a volume.
Hopefully the detail helps! That's everything I can think of off the top of my head right now, let me know if you can think of more information you need.
Thanks!
Kevin
macbri - Jan 17, 2008 - 10:22 am
Hi Kevin -
Thanks for the detailed info. Based on this I can set up a similar setup here, I should be able to get access to a server in a day or so. In the meantime, one thing you might try is to embed the username/password in the URL. So for example in your workflow you'd have:
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
afp://username

assword@XXX.XXX.XXX.XXX/volumeB
See what happens with that.
- Brian
khaworth - Jan 17, 2008 - 11:17 am
Hi Brian,
Well, I had some strange results, but it seems to be working.
If I used:
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
it would sometimes connect the first time, but if I ran it a second time it would always connect.
If I used:
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
Then it would always connect.
If I used:
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
afp://username

assword@XXX.XXX.XXX.XXX/volumeB
It would always connect to volumeA and sometimes volumeB.
If I used:
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
afp://username

assword@XXX.XXX.XXX.XXX/volumeA
afp://username

assword@XXX.XXX.XXX.XXX/volumeB
afp://username

assword@XXX.XXX.XXX.XXX/volumeB
it would always connect to both. So right now I have it setup so that each volume I want to mount is repeated.
I also found that I could leave the password out and then it would bring up the dialogue box asking for the password (which is preferable to having the password being so easy to be seen since my laptop sits in a semi-public place sometimes).
One other thing, every 10 times or so, after running the workflow the finder would restart. After restarting everything would be fine and the volumes mounted. So it's not a big deal, just strange.
Thanks for all your help. If a solution to having to double things up comes to you, I'd be interested. However, you've given me a workable solution and I'd understand if you want to move on to other tickets.
Thanks so much!
Kevin
macbri - Jan 17, 2008 - 8:53 pm
Hey Kevin -
You've done the majority of the sleuthing yourself on this one, I'm glad you have found a workaround that will suffice. I'll keep the ticket open for a while and do a bit more checking for a solution to the "doubling up".
khaworth - Jan 20, 2008 - 3:40 pm
Sounds great. Thanks Brian!
macbri - Jan 21, 2008 - 5:50 am
From some forums I looked at, AppleScript compiled as an application seemed to be the way some have gone, a simple one-liner such as:
mount volume "afp://username

assword@XXX.XXX.XXX.XXX/VolumeA"
Enter that in Script Editor, and save as an application. Does this still have the "doubling-up" problem for you?
khaworth - Jan 21, 2008 - 6:23 am
khaworth - Jan 21, 2008 - 6:28 am
Hi Brian,
Sorry about the blank response.
I meant to write back and say that if I typed exactly what you had, then it did seem to connect the first time. I switched it up to different volumes and each volume seemed to connect on the first try everytime.
I then tried typing the following into Script Editor:
mount volume "afp://username

assword@XXX.XXX.XXX.XXX/VolumeA"
mount volume "afp://username

assword@XXX.XXX.XXX.XXX/VolumeB"
When I do this, it mounts VolumeA, but then I get the following:
AppleScript Error
Disk some object wasn't found [sic -ed.]
Can I use a single script to mount multiple volumes at the same time (i.e. in the same script)? I have never used AppleScript before, so I don't know if this is jsut some syntax error where I need a semi-colon or something between lines or what not.
Thanks,
Kevin
khaworth - Jan 21, 2008 - 6:34 am
One more thing. I noticed that if I changed it to:
mount volume "afp://username@XXX.XXX.XXX.XXX/VolumeA"
(that is, I took out the password), then the first time the script (in script editor) I get the "Disk some object wasn't found" error and it does not connect. The second time I run it I do not get the error and it connects (without asking for a password, so it must be getting it from Keychain since I have not other volumes mounted such that a connection to that server is already setup). Now if I save the above as an application and run it. Again, I get the "Disc some object wasn't found" error (now in a dialogue box that allows me to click 'edit' or 'ok'). If I click okay then nothing happens. If I run the application a second time I again get the error, but this time it also mounts the volume.
I don't know if this info confuses the situation more or less, but I thought I'd pass it on.
If this just confuses it more, then I'll just keep the password in the script.
Thanks,
Kevin
khaworth - Jan 23, 2008 - 6:49 am
Brian,
this is just a quick note. I received an email saying that I had to put response up or the ticket would be closed. So this is just to keep the ticket open.
Kevin
macbri - Jan 23, 2008 - 8:33 am
I haven't found anything specific about this issue yet, will continue to research the problem...
khaworth - Jan 23, 2008 - 8:44 am
Brian,
I know this changes the topic a bit, but do you know if there is a way to make this connection securely (i.e. where the password is sent in an encrypted manner)?
No rush, I appreciate all your great help so far!
Kevin
macbri - Jan 24, 2008 - 5:35 pm
Hey Kevin -
Well, the password can be "stored" securely, as in with KeyChain, and then passed when appropriate, but whether the password is sent as clear text or not depends on the service you're connecting to. For example, older SAMBA servers could use unencrypted paswords, although I think that's largely a thing of the past. AFP can do either I believe.
For the "doubling up" problem, I haven't been able to duplicate the problem I'm afraid. But in reading about the topic i noticed that the AppleScript most people quote wraps the mount commands in a "tell application" statement:
tell application "Finder"
mount volume "afp://XXX.XXX.XXX.XXX/VolumeA
mount volume "afp://XXX.XXX.XXX.XXX/VolumeA
end tell
See if that helps in any way.
khaworth - Jan 27, 2008 - 8:13 pm
Hi Brian,
I still get errors using the tell command. I think I'll just work with the automator version we setup earlier. I'll probably take some time looking into setting up secure connections on my own. I appreciate all your help.
Kevin