Go Back   The macosxhints Forums > Working with OS X > OS X Developer



Reply
 
Thread Tools Rate Thread Display Modes
Old 06-08-2007, 10:25 AM   #1
TimEllis
Prospect
 
Join Date: Jun 2007
Posts: 5
Post Using AppleScript to Mount Network Shares

Hey,

I'm trying to write an AppleScript to mount a student's network file space. At present it mounts a share Users. They then have to open Students and find their username in a list of roughly 5000 names. I want it to go straight to their folder.

The AppleScript I have prompts for their username and password, but I can't get it to mount anything deeper than Users. I tried having the script look for a folder named Students but it can't even see that the folder exists. How would I get my AppleScript to mount this network share?
TimEllis is offline   Reply With Quote
Old 06-08-2007, 10:32 AM   #2
yellow
Moderator
 
Join Date: Jan 2002
Posts: 10,677
Is this an SMB share or AFP share?
yellow is offline   Reply With Quote
Old 06-08-2007, 10:37 AM   #3
TimEllis
Prospect
 
Join Date: Jun 2007
Posts: 5
It's an AFP share. I looked all over but can't find anything about mapping more than one share deep.
TimEllis is offline   Reply With Quote
Old 06-08-2007, 11:43 AM   #4
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
well

Code:
tell application "finder"

mount afp://ip.of.share

end tell
That is just a simple version of it, however how are the user's authenticating? AD, OD, LDAP? It sounds like there is more to it than we know.
tlarkin is offline   Reply With Quote
Old 06-08-2007, 11:53 AM   #5
TimEllis
Prospect
 
Join Date: Jun 2007
Posts: 5
Users authenticate through Active Directory. My script presently tells it to

Mount "afp://" & user_name & ":" & pass_word & "@files.geneseo.edu/Users/"

Where user_name and pass_word are input by the user. However, if I run a check to see if the Students folder exists in there, it says it isn't, when it clearly is. If I try to mount "afp://" & user_name & ":" & pass_word & "@files.geneseo.edu/Users/Students/" & user_name it still just mounts Users.
TimEllis is offline   Reply With Quote
Old 06-08-2007, 12:16 PM   #6
yellow
Moderator
 
Join Date: Jan 2002
Posts: 10,677
I believe that is a function (or curse) of mounts served from a Windows server. You could try and add a $ to the end of the user's name.
yellow is offline   Reply With Quote
Old 06-08-2007, 12:46 PM   #7
cwtnospam
League Commissioner
 
Join Date: Jan 2005
Posts: 8,475
From the Applescript dictionary:
Quote:
mount volume?v : Mount the specified AppleShare volume
mount volume string : the name or URL path (starting with ‘afp://’) of the volume to mount
on server string : the server on which the volume resides; omit if URL path provided
[in AppleTalk zone string] : the AppleTalk zone in which the server resides; omit if URL path provided
[as user name string] : the user name with which to log in to the server; omit for guest access
[with password string] : the password for the user name; omit for guest access

cwtnospam is offline   Reply With Quote
Old 06-08-2007, 01:13 PM   #8
TimEllis
Prospect
 
Join Date: Jun 2007
Posts: 5
Here is the whole AppleScript

Quote:
property user_name : ""
property pass_word : ""
property network_share : ""

tell application "Finder"
if user_name is "" then
set dialog_1 to display dialog "Please enter your username: " default answer ""
set the user_name to the text returned of dialog_1
end if

if pass_word is "" then
set dialog_2 to display dialog "Please enter your password: " default answer "" with hidden answer
set the pass_word to the text returned of dialog_2
end if

set network_share to "afp://" & user_name & ":" & pass_word & "@files.geneseo.edu/Users/"

mount volume network_share
make new Finder window
set target of Finder window 1 to folder "Users"
delay 2
if (exists folder "Students") then
display dialog ("It's there")
else
display dialog ("It's not there")
end if

end tell

There is a folder named Students in Users, but it returns with "It's not there" as if there is no such folder. Where would I put a $? Thanks a ton.
TimEllis is offline   Reply With Quote
Old 06-08-2007, 01:17 PM   #9
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
I am not quite grasping something here, and sometimes I just need to be told something flat out.....Are you ultimately trying to map Home directories? From a server? What type with what OS?

There are many other ways to do this with out apple scripting, that is why I ask.

Also, do the users authenticate to some sort of directory service or locally on the machine?
tlarkin is offline   Reply With Quote
Old 06-08-2007, 01:24 PM   #10
cwtnospam
League Commissioner
 
Join Date: Jan 2005
Posts: 8,475
Try something like this:
Code:
	mount volume "afp://192.168.0.101/volumename" as user name "username" with password "yourpassword"
It works connecting to my wife's machine.
cwtnospam is offline   Reply With Quote
Old 06-08-2007, 01:47 PM   #11
TimEllis
Prospect
 
Join Date: Jun 2007
Posts: 5
The students have server space on our "files" server. They are not trying to map home directories. This will be used on Mac OS X machines.

This script maps to the network share, but it is only seeing one directory deep for some reason. It only sees the first directory regardless of what volume I mount.

They authenticate to a directory service, but log into the machine locally.
TimEllis is offline   Reply With Quote
Old 06-08-2007, 03:44 PM   #12
tlarkin
League Commissioner
 
Join Date: Mar 2003
Location: Bay Area, CA
Posts: 11,352
these shares require authentication? Or is there no ownership involved?

you can try

mount afp://%user%@ip.of.share/path /mount/path

but why not use the directory service to push out the shares?
tlarkin is offline   Reply With Quote
Old 06-26-2007, 08:58 AM   #13
krehbiet
Registered User
 
Join Date: Jun 2007
Posts: 1
I'm not sure why he would want to do something like this, but I work in an environment where we don't login to the machines individually. So thanks to your help I have a script now that lets me mount a users home directory after they run the script and type in their user name and pass. Thanks everyone.

At this point I am really happy with it, I'll simply put it on the desktop of all the machines and teach everyone how to use it, much easier then browsing to the server...

Anyone know if its possible to have the username and password be one dialog box and not 2?

to getusername()

display dialog "Enter your username:" default answer ""

set username to text returned of result

return {username}

end getusername

to getuserpwd()

display dialog "Enter your password:" default answer "" with hidden answer

set userpwd to text returned of result

return {userpwd}

end getuserpwd

set username to getusername()

set userpass to getuserpwd()


tell application "Finder"

open location "afp://" & username & ":" & userpass & "@172.16.100.11/" & username

end tell
krehbiet is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 10:06 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.