Newbie Plea - Button Issue

This is my second time posting this question, but I am desperate for an answer…
While doing a testing script in OS 10.1.x I run into a problem where a dialog box pops up with a warning. I need to either (a) supress any warnings or (b) have the script click OK so the dialog goes away.
I am getting the warning when trashing an item that is located on a file server… It comes back with a warning that the item cannot remain in the trash and must be deleted immediately… If there is any way to make this go away I’d love to know.
Much gratitude!!

: I’m not convinced about that, Krioni. What would be against, for instance,
: getting the number(s) of the error(s) in question and then using it/them
: (instead of the ‘12345’) in: try
: – whatever
: on error number errNum
: if errNum 12345 then – etc
: – display dlog or other action
: end if
: end try …enabling a choice to be made of even having no dlog at
: all for certain errors? That would ‘dispose’ of the dlog box problem, and
: the script would then need to trash the file(s) in question if it exists.
: Not having a setup to test any of this I am just speculating, but why
: couldn’t this be implemented? Am I missing something?

The problem is that the dialog box is not an error, it is a natural function of deleting files off of a network disk when using the Finder. The problem is that the delete command in the Finder’s dictionary doesn’t have an option to delete ‘with prejudice’ :slight_smile: Pun intended.

Well, well - I’ve seen that message countless times as I juggle my local disks (b/u, archive, whatever) around, and never guessed that it was anything other than an ordinary error dlog. Out of curiosity I just tried ‘trapping’ the msg as an error and, of course, you couldn’t be more right - it remains totally aloof to such appeals.
Thank you, Krioni, for Y-A-morsel of cerebral fodder.

Dog with a bone here. Is it thinkable that someone with the requisite know-how might do a Jon’s deleteFile simulation and remove the file from the directory? I understand that the directory structure in X is easier to deal with than previously, but I would still guess that any answer along those lines must await the X-ification of Jon - or is it actually feasible?
In the meantime I would have thought your method, Krioni, more than acceptable - all data destroyed, leaving just a completely inocuous little file that can’t bite anyone.

: I shouldn’t be answering you because I haven’t got X, but you may try
: something along these lines. Firstly make certain that you are in charge
: of the display of the dlog by, say, having it appear in a ‘try - on
: error…’ loop. Then maybe all you need is: display dialog
: “Now you see me…” giving up after 1

: Unfortunately this does need an osax - Standard Additions. I gather that a
: few osaxen do work in X. Will this? I’ve no idea - over to you.

: Andreas

The problem he’s describing is a dialog box popping up that he didn’t create. He describes the dialog box as a warning about deleting a file on a server.

There may be no way to capture this dialog. The only thing I can think of is to replace the item with a junk file:

move someJunkFile to networkDiskFolder with replacing

This won’t show a dialog box, but it also will leave the junk file on the server. Another possibility is to enable Secure Shell login and wipe the file out using Terminal or ‘do shell script’ commands.

I’m not convinced about that, Krioni. What would be against, for instance, getting the number(s) of the error(s) in question and then using it/them (instead of the ‘12345’) in: try
– whatever
on error number errNum
if errNum 12345 then – etc
– display dlog or other action
end if
end try Éenabling a choice to be made of even having no dlog at all for certain errors? That would ‘dispose’ of the dlog box problem, and the script would then need to trash the file(s) in question if it exists. Not having a setup to test any of this I am just speculating, but why couldn’t this be implemented? Am I missing something?
Andreas

Hi everybody,
Would this work? Just before you delete the file, ‘launch’ an application that monitors the trash, deletes any added files, and quits. You could use an idle handler like this:

on idle 
 tell application "Finder" 
  set trash_items to (every item of trash) 
 end tell 
 if trash_items is not {} then 
  tell application "Finder" to empty 
  quit 
 end if 
 return 1 
end idle 

I tried testing it with the ‘display dialog’ command with this:

set the_file to (choose file) 
tell application "TrashMan" 
 launch 
 idle 
end tell 
tell application "Finder" 
 delete the_file 
end tell 
repeat 
 try 
  display dialog "Try to empty the trash." 
 on error 
  exit repeat 
 end try 
end repeat

Warning: the file you choose will be deleted if it works like it did on my machine.
gl,
Kel.

: p.s. the purpose of this script is to test an OS X system on our companie’s
: new Cisco network, so what the script is supposed to do is: • turn
: AppleTalk on • connect to a server • copy a file to server • copy a file
: from server • delete both files • disconnect from server • turn AppleTalk
: off
: I had the script running fine with OS 9 , but unfortunately OS X has not been
: as friendly of a beast as it’s predecessor… oh well.
Wait a sec! If you’re running OS X, you can do what I suggested in my first response: have AppleScript do a shell command that deletes the file.
So, if you’re network volume was Software, the file was named myFile.rtf in the folder TestFile, you’d run the following:
do shell script ‘rm /Volumes/Software/TestFile/myFile.rtf’
– a ‘rm’ or remove command, with the full UNIX-style path – make sure you put quotes around it, in case you have spaces in the path. Or, escape the characters (read more elsewhere)
That will delete the file with no warning message, I believe.

What it sounds like to me is that, he drags the file from the network disk to the trash. Then, the warning comes up that the trash needs to be emptied. Then, he goes to empty the trash. Then, the other dialog comes up that says that you can turn off this warning (trash emptying warning) or press “OK”. Then, the other dialog goes away.
About the second warning (the one when emptying the trash), can’t you get info on the trash and turn it off in the info window. But, I think that using AppleScript ‘empty’ command bypasses that warning anyway.

: Hi everybody,
: Would this work? Just before you delete the file, ‘launch’ an application
: that monitors the trash, deletes any added files, and quits.
Is that why the “immediate delete” happens? Ff there are files already in the trash, and you try to move a network file there, it will be deleted immediately, since the trash would otherwise be a mix of local and network files?
So, you’re saying that if the trash is empty before you try to put a file in it from a network disk, you don’t get that message?

Thanks to everyone on their help here, but I am still at an absolute loss… after combing through dictionaries, the AppleScript Language guide and several hours of just trial an error I have come to the conclusion that I am doomed and that AppleScript hates me… all jokes aside, thanks for your responses, If I can ever get the script to actually work, I will let you know… thanks!!
p.s. the purpose of this script is to test an OS X system on our companie’s new Cisco network, so what the script is supposed to do is:
• turn AppleTalk on • connect to a server • copy a file to server • copy a file from server • delete both files • disconnect from server • turn AppleTalk off
I had the script running fine with OS 9 , but unfortunately OS X has not been as friendly of a beast as it’s predecessor… oh well.

Hi Krioni,
I see what you’re saying now. I wasn’t thinking about the case where there are originally local items in the trash. Sorry, I never leave anything in the trash. I made it one-shot so that it wouldn’t just keep on emptying when things where added to the trash. In the script that’s launching the “TrashMan” script, they can move items out of the trash first if its the case that they leave needed items in there or just empty it before hand.
Can’t test this out here. This was just an idea that someone might checkout or disregard.
Kel.

No. He specifically said what the issue is: He tries to ‘delete’ a file, which in AppleScript, just moves it to the trash. The problem is, with some networks disks, a dialog pops up immediately, saying that this file, because it is on a network disk (doesn’t happen for all network disks), will be deleted immediately. That’s delete in the complete sense of the word. Some network disks do not allow you to keep a file in the trash. When you try to put it there, you get the warning that it will be completely deleted immediately. So, his problem is that the dialog that pops up is a built-in part of the Finder, designed to prevent people from accidentally permanently deleting a file. Now, he can work around it using Mac OS 9 by using Akua Sweets’ kill (I think that’s the name) command.
In Mac OS X, he can get around it by using a ‘do shell script “rm suchandsuch”’ command, which will bypass any Finder warning.
Those solutions will work, and solve his problem, with no dialog box. I can’t test the Akua Sweets issue here, but hopefully he can.
: What it sounds like to me is that, he drags the file from the network disk to
: the trash. Then, the warning comes up that the trash needs to be emptied.
: Then, he goes to empty the trash. Then, the other dialog comes up that
: says that you can turn off this warning (trash emptying warning) or press
: “OK”. Then, the other dialog goes away.
: About the second warning (the one when emptying the trash), can’t you get
: info on the trash and turn it off in the info window. But, I think that
: using AppleScript ‘empty’ command bypasses that warning anyway.

Hi Krioni,
Thanks for the info. I took it diffierently because he said “It comes back with a warning that the item cannot remain in the trash and must be deleted immediately…”.
Have a good day, Kel.