Suppressing a finder dialog?

Hello

I have written a small application that collects data from a mounted SMB share every 15 minutes while the machine is running. This data is stored in a local instance of MySQL, and when the share is mounted all is well.

If, when the application runs (written in Java), the given share is not accessible, it calls an AppleScript imaginatively entitled “Open Share” via the terminal.

The problem is, if away from my desk for the day, and a problem occurs (what the problem is, I’m not sure, but once it’s broken its broken on every successive call), it will try all day and when I come in the next day I have around 100 finder dialogs in which to click OK. Very frustrating. The original script was:

tell application "Finder"
	try
		open location "smb://Waperfile02/Data"
	end try
end tell

I then tried to suppress the error message via the following (writing a log entry of the occurence):

tell application "Finder"
	try
		open location "smb://Waperfile02/Data"
	on error error_message number error_number
		set this_error to "Error: " & error_number & ". " & ¬
			error_message & return
		-- change the following line to the name and location desired
		set the log_file to ((path to desktop) as text) & "Script Error Log"
		my write_to_file(this_error, log_file, true)
	end try
end tell
on write_to_file(this_data, target_file, append_data)
	try
		set the target_file to the target_file as text
		set the open_target_file to ¬
			open for access file target_file with write permission
		if append_data is false then ¬
			set eof of the open_target_file to 0
		write this_data to the open_target_file starting at eof
		close access the open_target_file
		return true
	on error
		try
			close access file target_file
		end try
		return false
	end try
end write_to_file

This does not work. The dialog still displays.

My question is whether anyone knows either
a) a more reliable way to mount a file share (this works as password is stored in keychain btw); or
b) whether there is a way to “suppress” or “catch” the error message before the dialog is created in the finder.

Any help would be much appreciated.

Cheers
Tom

Model: Mac Mini
AppleScript: OS X 10.4.5
Browser: Firefox 1.5.1
Operating System: Mac OS X (10.4)

What did these dialogs say?

Open location “ which “opens a URL with the appropriate program” “ is part of Standard Additions, not Finder.

Hi Bruce

Unfortunately I didn’t write down the exact text, but it is something along the lines of connection failure (-36).

The script works 80% of the time, then occassionally when I’m not at the machine it stops working and won’t come back to correctly mounting (just fails and fails) until I unmount the shares (sometimes 4 or 5 of the same) and manually mount it via an alias in the dock. I never log out, and the machine is sleep at the end of the day, wake in the morning.

In terms of standard additions, does this mean I shouldn’t be using “tell finder”?

BTW: I had been calling the AppleScipt direct from the Java byte-code using the NSAppleScript bridge, although either way the dialog issue remains.

Yes. Also, would “mount volume” be of any use to you? (It’s part of Standard Additions too.)

That sounds like a good idea - I’ll try that.

I’ll let you know how I get on.

Thanks.

I’m now in testing, seeing how this AppleScript will hold up over a longer period - but so far so good: many thanks.