automount sharepoints

I have been using a simple script to mount an OSX Server share point. I have used both IP address and the server name in the script. Either way works. I will soon need to run this script on OSX workstaions in a managed client environment at 40 different locations. I would like to use a variable for the servername such as “localserver”. Is there a script I can enter before the mount volume script that will set a variable to the servername.local?

This is the script as it is now.

tell application “Finder”
activate
mount volume “afp://user_name:password@serverIP/share_name”
end tell

You can enclose text in a variable as follow:

set x to "foo"
--> or
set x to text returned of (display dialog "Enter server name:" default answer "bar")

And you can use it later as follow:

mount volume ("afp://usr:pwd@" & x & "/share_name")
  • NOTE that you don’t need the Finder to call “mount volume”, which is part of the Standard Additions osax.

Thank you JJ, this will move me in the right direction.

Is there anyway that AppleScript can get the severname automatically through the script so that there is no user intervention on need to create a modified script for each of the LANs I need this for?

If not, can a script run that tests for the IP address of the server and then use that for the mount volume portion?

Paul

Do you mean auto-discover servers/machines in the LAN? I don’t know. I think it can be done using one of those *nix tools “arp” or something similar, but I don’t know how. You could call this using a “do shell script” command. This would work here, but not sure if it will for you:

set availableMachines to paragraphs of (do shell script "arp -a | awk '{print $2}'")
--> {"(192.168.200.2)", "(192.168.200.254)"} --> in my machine

--> eg
set machineToConnectTo to text 2 thru -2 of availableMachines's item 1 --> "192.168.200.2"

mount volume "afp://user:pwd@" & machineToConnectTo & "/share-name"

Thanks again jj.

I will take this in to work tomorrow and see what I can do.
Yes, I an trying to auto-discover the name or IP address of a server in the LAN so that I can use that information in the script to mount sharepoints.

Paul