Problem upgrading OS9 script to OS X

The newspaper where I work is making the slow (and sometimes painful) migration from Mac OS 9.x to Mac OS 10.x. As the resident OS 9 AppleScript specialist, I get to update and rewrite the 40 or so scripts our users run daily, and one has stumped me:

Our Mac users connect to Mac shares on Windows 2000 servers via SMB, and they need to mount five or more volumes every time they log in. With 10.2.8, Connect to Server requires users to log in once for each volume, a move that would get me burned at the stake.

Here is the code I’ve written so far (with a lot of help from previous postings on this BBS. Thanks, everyone!)


list disks
set disklist to result
if disklist does not contain "volume1" then mount volume "smb://(domain);(server)/(volume1)"
end if

if disklist does not contain "volume2" then mount volume "smb://(domain);(server)/(volume2)"
end if

And so on. Again, the problem is that a user has to log on to each volume. Adding a user name and password works, of course, but security issues prevent going that route. Does anyone have any ideas about how to do this?

wouldn’t it be something like this:

mount volume “smb://username:password@server ip/volume name_1”
mount volume “smb://username:password@server ip/volume name_2”
mount volume “smb://username:password@server ip/volume name_3”
mount volume “smb://username:password@server ip/volume name_4”
mount volume “smb://username:password@server ip/volume name_5”
mount volume “smb://username:password@server ip/volume name_6”

It would if I could get away with allowing a user name and password to reside inside the AppleScript. But because of security concerns, I can’t do that. Beyond that, the script will support more than 100 users, allowing them to log on to one server using any Mac in their departments, so it can’t be user-specific.

If I take out the user name and password from the script, the user is prompted to log in for each volume, which would be too clunky. What I had hoped for was an idea that could allow users to log in once – with user name and password – to mount all the volumes. Any ideas?

If it’s always the same username & password, you can ask for it once (which won’t keep store it in the script) and then use it for each login. The problem with this is that the password field is not obscured. You could easily get around this using a Scripting Addition (see askPassword in System.osax) or by developing a very simple app in AppleScript Studio. Just using vanilla AS, this should work:

set user_name to text returned of (display dialog "Username:" default answer "" buttons {"OK"} default button 1 with icon 1)
set pass_word to text returned of (display dialog "Password:" default answer "" buttons {"OK"} default button 1 with icon 1)

mount volume "smb://" & user_name & ":" & pass_word & "@server ip/volume name_1"
mount volume "smb://" & user_name & ":" & pass_word & "@server ip/volume name_2"
mount volume "smb://" & user_name & ":" & pass_word & "@server ip/volume name_3"
mount volume "smb://" & user_name & ":" & pass_word & "@server ip/volume name_4"
mount volume "smb://" & user_name & ":" & pass_word & "@server ip/volume name_5"
mount volume "smb://" & user_name & ":" & pass_word & "@server ip/volume name_6"

Jon

Thanks, Jon. The vanilla AppleScript you mentioned leads to a “network file permissions error”, but I think that may be more related to our Win2K servers than OS X. I’ll keep plugging away. Thanks for your help.

My problem was that I forgot to reset the default domain in the script. Once I did that, it worked like a charm. Thanks again, Jon, and everyone on the MacScripter BBS for their script advice and samples.

guys how to reset the default domain ?

i have another problem , i ran the script as above, and now when i try to connect it give me a error

it say" login failed , sorry the password you entered is incorrect please reenter it."

i didnt change the password or the login name so something in the script cause it to fail ,

so any kind soul can provide the solution will be most appericated.

roychean
roychean@yahoo.com

Here is the code exactly how I run it. I repeat the if … end if part as necessary to mount additional volumes. Note the part where the domain goes. All networking issues aside, you can change the domain there and it should work. Also note that I have not tested this script with AFP, only SMB.


set user_name to text returned of (display dialog "What is your user name?" default answer "" buttons {"OK"} default button 1 with icon 1)
set pass_word to text returned of (display dialog "What is your password?" default answer "" buttons {"OK"} default button 1 with icon 1)

list disks
set disklist to result

if disklist does not contain "volume" then
	mount volume "smb://domain;" & user_name & ":" & pass_word & "@server/volume"
end if