A folder action to ftp the added item

Hi there,

Trying to figure out how to use a folder action to ftp the added item - something along the lines

on adding folder items to this_folder after receiving these_items
tell application “Terminal”
do script "ftp -i -n <<END
open ftp.xxx.xxx
user aaa bbb
bin
put ???
close
END "
end tell
end adding folder items to

But how do I tell Terminal which file to put?
Obviously Terminal doesn’t understand ‘these_items’

Or is there a simpler way?

thanks for any help
/erik

Good news, I have just the script you are looking for.
Bad news, it only worked for me under OS 9.

More news, I’m in the hunt for conversion/ateration/kick in the head on how to make this work in OS 10.3 - soooo, if anyone has any ideas, please let me know.

Anyhoo,
Here’s the script - replace username and password and your server’s directory info as need in the one line that had ftp location below… Good luck!

on adding folder items to thisFolder after receiving fileList
set ftpURL to “ftp://username:password@yourwebsite.com/youruploadareahere/
repeat with i in fileList
tell application “Finder” to set thisFileType to the file type of i
try
tell application “URL Access Scripting”
activate
if thisFileType is “TEXT” then
upload i to ftpURL replacing yes with progress and authentication
else
– delete the return between “binhexing” and “and” in the next line
upload i to ftpURL replacing yes with authentication without binhexing
end if
end tell
on error errMsg number errNum
display dialog (errNum as string) & ": " & errMsg
end try
end repeat
tell application “URL Access Scripting” to quit
end adding folder items to

This was a workhorse for me under OS9.
It adds any file dropped into it to the server locatin defined.

I hope this helps, and again, if OS 10.3 compatability/usage crop up PLEASE LET ME KNOW, I’m dying to use same on OS 10.3…

Cheers!
Greg.

Greg,
Thanx for the tip - not that it helped much…
URL Access Scripting looks simple, but I’ve had no luck so far actually making it work.

In the meantime osXigen from www.jomosoft.com or
FTPDroplet from www.subrosasoft.com will do the trick

/erik

I’ve done folder action to Distiller Out folder to send pdf files:

property pdf_storage : "MacHD:PDF_Storage"
property print_ftp : "ftp://user:password@ftp.server.fi"
property log_file : "MacHD:logs:server.log"
property pdf_out : "MacHD:print_pdf:Out" --this is distiller out folder of this folder action script
property HT : ASCII character 9
property CR : ASCII character 10
property ps_ext : "ps"
property pdf_ext : "pdf"
property log_ext : "log"

on adding folder items to this_folder after receiving these_items
	tell application "Finder"
		try
			repeat with i from 1 to number of items in these_items
				set this_item to item i of these_items
				if the name extension of this_item is pdf_ext then
					set this_date to (current date) as string
					try
						with timeout of 300 seconds
							do shell script "curl -T " & (quoted form of POSIX path of this_item) & " " & print_ftp
						end timeout
						move this_item to pdf_storage with replacing
						set write_file to (open for access file log_file with write permission)
						write this_date & HT & this_item & " OK" & CR as string to write_file starting at eof
						close access write_file
						set the creator type of the file log_file to "R*ch"
					on error
						set write_file to (open for access file log_file with write permission)
						write this_date & HT & this_item & " FAIL" & CR as string to write_file starting at eof
						close access write_file
						set the creator type of the file log_file to "R*ch"
						move this_item to pdf_out with replacing
					end try
				end if
			end repeat
		on error
			close access write_file
		end try
	end tell
end adding folder items to

Jukka