AppleScript - Automator Simple FTP Solution

Running MAC OS X 10.6
I’m fairly new to MAC’s I’ve owned a IMac for about 6 months and a Macbook Air for 5 days. That’s it.
I have past limited programming experience in Basic and Visual Basic and writing batch files under windows and dos. I’m really a NOOB at Mac programming and scripting. I’m in real estate not a programmer or a tech guy.
I spent hours of research trial & error on this, so I thought I’d post my findings.

I have one database file and I need to have a copy uploaded to an FTP server periodically.
The user who enters data into the database is not very computer literate so I needed a very simple way that they could click a single icon on the desk top and the file would automatically upload. I did not want the user to have to open an FTP client, navigate finder to locate the database file, login to the FTP server, etc. Needed to be a one click idiot proof solution. The database file name and location would not change.

Obviously MAC’s own Finder actions in AppleScript will not work since Apple only supports download from an FTP site (why they limited this I don’t know). The download actions via AppleScript work well. Just won’t upload. Only took this NOOB about 3 hours to discover this…

Several people suggested curl. Way over my head for a NOOB.

Tried URL Access Scripting. Played with this for about 4 hours, using examples from this forum, never could get it to work. Might be a OS version issue. Don’t know.

Tried down loading CyberDuck and writing a script to control it. No Joy.

What finally worked was Fetch. Down loaded the trial version to start. When lauching Fetch for the first time hold down the option key and click on the Fetch Icon, that will load the actions into the AppleScript Library. Used Automator to build a script application. Two steps. First user the Finder Action to Select the files you want to upload. Then use the Fetch action “Upload Files” to upload to your FTP site. Save the application and place on your desktop. Amazing simple.

Only wish I could find a way for the Fetch application to exit once the upload is complete. Right now the Fetch application window remains open after the upload is complete. Will have to work on that. I seem to remember a script command to close a window, just need to look up the syntax and put it in my script.

Cheers.
ScottyD.

Model: Macbook Air
Browser: Internet Explorer 8.0
Operating System: Mac OS X (10.6)

Regarding URL Access Scripting, I’ve never had an issue. Here’s the script I use. Just setup the 5 variables at the top of the script.

set ftpHost to "myHost.myServer.com"
set ftpUserName to "userName"
set ftpPassword to "password"

set localPath to (path to desktop as text) & "test.txt"
set remotePath to "/test.txt"

set ftpURL to "ftp://" & ftpUserName & ":" & ftpPassword & "@" & ftpHost & remotePath
tell application "URL Access Scripting"
	upload file localPath to ftpURL replacing yes without binhexing
end tell

URL Access Scripting works SOMETIMES for me. It’s really annoying.

To have Fetch quit after the upload, add a “Run AppleScript” action to the end of the workflow and enter:


tell app "Fetch"
    quit
end tell


Jim Matthews
Fetch Softworks