Compatibility error?

I’ve written the following script in Applescript in Snow Leopard, and I tried to use it in Mountain Lion, but to no avail (doesn’t work). The script watches a folder for added files, and if the filetype matches, it will scp it to a server.

It runs great, no errors on Snow Leopard. When it’s run in ML it spits back the error (in console):

AppleScript Runner: CPSGetFrontProcess():

This call is deprecated and should not be called anymore.
I’m almost positive this has something to do with the way the script is written. I have tried copying & pasting into a new script in mountain lion, and then saving that. Doesn’t work either.

Here is the code itself, any insight as to what’s going wrong?

on adding folder items to this_folder after receiving the_files

--set login vars
set fileExt to "zip"
set scpIP to "blah"
set scpUser to "blah"
set scpDest to "/home/blah"
set scpPort to "1234"

--repeat on each file that is added to the folder
repeat with each_file in the_files
    set filename to name of (info for each_file)
    tell application "Finder"
        --check extension, if match, scp. else, error.
        if name extension of each_file is fileExt then
            try
                do shell script "scp -p" & scpPort & " " & scpUser & "@" & scpIP & ":" & scpDes
                move each_file to trash
            end try
        end if
    end tell
end repeat

end adding folder items to

To get the name of the file you can simply tell Finder

set filename to name of each_file

“Info for” is deprecated

on adding folder items to this_folder after receiving the_files
	
	--set login vars
	set fileExt to "zip"
	set scpIP to "blah"
	set scpUser to "blah"
	set scpDest to "/home/blah"
	set scpPort to "1234"
	
	--repeat on each file that is added to the folder
	repeat with each_file in the_files
		tell application "Finder"
			set filename to name of each_file
			--check extension, if match, scp. else, error.
			if name extension of each_file is fileExt then
				try
					do shell script "scp -p" & scpPort & " " & scpUser & "@" & scpIP & ":" & scpDes
					move each_file to trash
				end try
			end if
		end tell
	end repeat
	
end adding folder items to

Great, that fixes the script so that it works, but I’m still getting the same error from console. Here is a screenshot of the three errors I am getting. I am using nearly the exact script that adayzdone posted above.

http://cl.ly/image/281M0B0E150K

For some reason, it’s trying to set the front application to Finder? This script still “works”, but if it’s giving me depreciated call errors it’s slowing it down a ton. Any ideas?

It’s also giving me a bit of difficulty with the “do shell script” command - does anyone know if I’m using that incorrectly or something else?

Hello!

Maybe it would work better if the script is reworked to use System Events instead, as System Events is a process not running in foreground.

Hi SoFLy,

After seeing your deprecated comment, I did not thoroughly read the rest of your script.

The line

do shell script "scp -p" & scpPort & " " & scpUser & "@" & scpIP & ":" & scpDes

uses a variable scpDes. However, you declare the variable as scpDest above. Also, scp -p" should be scp -p ".

See if this works for you.

set xxx to "scp -p " & scpPort & space & scpUser & "@" & scpIP & ":" & scpDest

I made the fixes you guys suggested & everything worked well, but the error “AppleScript Runner: CPSGetFrontProcess():” still displays. I did some research, and found this thread:

http://hintsforums.macworld.com/showthread.php?t=80931

Seems like this may be a deeper issue, and people are still dealing with it. Don’t think I’ll end up doing this one in Applescript :confused: