Stuck with Applescript Syntax Error... please help

I keep getting the message "Syntax Error…Expected “given”, “into”, “with”, “without” or other permission name but found end of line. – Please help, I am unsure as to how to correct this

I am trying to write an application that will allow me to delete certain files on the computer and provide me with any error messages using text edit.

The school I am at is decommissioning some computers so I need to delete multiple files on multiple machines. I thought this applescript would help to ensure I did not forget to delete any thing.

What I am trying to do exactly…

  1. Have both a growl and a dialog box message appear
  2. Delete the specified files
  3. Generate an error report
  4. Have a final growl message and dialog box appear
  5. Have the computer restart

I would prefer having the error message show up in a dialog box, but I do not think it is possible.

Thank you for your help.

Regards,
paulmattallen

Applescript Names I was thinking of were Deleter, or Seppuku…



--this script will automatically find, locate, and delete specified files. Then it will secure empty the trash. If some of the files were not on the computer then a report will be generated.

--list files as follows {"/Applications/Safari.app", "/Applications/Shared Drive.app"}

on run
	
	--growl 1
	tell application "GrowlHelperApp"
		set the allNotificationsList to {"Test Connection"}
		set the enabledNotificationsList to {"Test Connection"} -- ** just one turned on, the other not.
		register as application "login_items_v6" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "login_items_v6"
		
		--	Send Growl Notification...
		notify with name "Test Connection" title "Warning!" description "Do you really want to erase the School Software off this hard drive?

Once this program is acticated it cannot be undone." application name "login_items_v6"
	end tell
	
	delay 1
	
	--dialog box
	display dialog "Do you really want to erase the School Software off this hard drive?

Once this program is acticated it cannot be undone.

If you do not wish to do this select cancel." with icon caution with title "Warning!" giving up after 10 buttons {"Cancel"}
	
	do shell script "command" user name "My School Computer" password "1234t" with administrator privileges
	
	set itempaths to {"/Applications/deleter copy.scpt", "/Applications/images", "/Applications/Seppuku copy"}
	
	set report to ""
	repeat with itempath in itempaths
		if not my itempathexists(itempath) then
			set entry to "Could not locate item '" & itempath & "'" & return
			set report to report & entry
		else
			try
				set command to "rm -rf " & quoted form of itempath
				do shell script command with administrator privileges
				
			on error errmsg
				set entry to "Deleting the following item failed:" & return & tab & itempath & return & errmsg & return
				set report to report & entry
			end try
		end if
	end repeat
	
--empty the trash	
do shell script "/usr/bin/srm -mz $HOME/.Trash/*" with administrator privileges
	
	
	if report is not "" then
		tell application "TextEdit"
			activate
			if not (exists document 1) then
				make new document
			end if
			set text of document 1 to report
		end tell
	end if
end run

on itempathexists(itempath)
	try
		set itemalias to (POSIX file itempath) as alias
		return true
	on error
		return false
	end try
end itempathexists

--closedown
on closedown
--growl 2
tell application "GrowlHelperApp"
	set the allNotificationsList to {"Test Connection"}
	set the enabledNotificationsList to {"Test Connection"} -- ** just one turned on, the other not.
	register as application "login_items_v6" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "login_items_v6"
	
	--	Send Growl Notification...
	notify with name "Test Connection" title "Seppuku is complete!" description "The system will shut down now." application name "login_items_v6"
end tell

delay 1

--dialog box 2
display dialog "The system will shutdown now." with icon caution with title "Seppuku is complete!" giving up after 5 buttons {"Shutdown", "Cancel"}


--shutdown command
set normal_command to "shutdown -h now; command2"
do shell script "sh -c " & quoted form of normal_command with administrator privileges
end closedown

Hi,

handlers are defined by the name plus a pair of parentheses

on closedown()

Thank you soo much! I cannot believe I forgot to add that.

Best Regards,
paulmattallen