How do you redirect errors from an external application

As before I’m trying to make it easier for my users to logon on to their folders on a win2k server. The problem i have now is that their account may be on one of three servers. How do I go about getting my script to recognise that there account isn’t on the main server but on the secondary or tercery server and to try to mount that server instead.

Or if you have a better way of doing it please tell me

on clicked theObject
tell window of theObject
try
set theUsername to contents of text field “username” as text
set thePassword to contents of text field “password” as text
end try
end tell

tell application "Finder"
	try
		mount volume ("smb://" & theUsername & ":" & thePassword & "@10.0.1.13/" & theUsername & "")
	on error
		mount volume ("smb://" & theUsername & ":" & thePassword & "@10.0.1.12/" & theUsername & "")
	end try
end tell
tell window of theObject
	set contents of text field "username" to ""
	set contents of text field "password" to ""
	display dialog ("Drive for " & theUsername & " has been mounted")
end tell

end clicked[/b]

The other way would be to (if possible) set the script to generate a file with all of the shares available on each server(may be seperate files for each server) and then interigate the file to discover which server has the share relevant to that account, the same list that you get when you connect to a machine through “connect to server” or “chooser”. As you may have guessed the sharename and account name are the same.

I’d just change the following part slightly.


tell application "Finder"
	set serverList to {"10.0.1.13", "10.0.1.12"}
	repeat with oneServer in serverList
		set oneServer to contents of oneServer -- dereference, just in case
		try
			mount volume ("smb://" & theUsername & ":" & thePassword & "@" & oneServer & "/" & theUsername & "")
			set serverLoaded to true
			exit repeat
		on error
			-- just keep trying
			set serverLoaded to false
		end try
	end repeat
	if serverLoaded is false then
		display dialog "Could not load the server."
	end if
end tell