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)