I have the following script to connect to an FTP server:
set ftpLogon to "ftp://username:password@server.com/path/to/whatever"
mount volume ftpLogon
set remoteFolder to "Volumes:" & "server.com"
The script does work. I can get a list of the files, however, when I download and edit them, I can no longer upload them to the FTP server. It tells me something about me not having the rights to write files. How can get these permissions?
I recommend to use curl for that job.
Here a sample code to upload and download a file.
With curl you can also read a directory on the ftp server
property ftpserverPath : "[url=ftp://ftp.myServer.com/path/to/Folder/]ftp.myServer.com/path/to/Folder/[/url]"
property user_name : "user"
property pass_word : "pass"
property theFile : "myFile.txt"
set serverURL to (ftpserverPath & theFile)
set tempFile to POSIX path of (path to desktop) & theFile
curl_download(serverURL, tempFile)
curl_upload(tempFile, serverURL)
on curl_download(|source|, dest)
do shell script "curl -o " & quoted form of dest & " -u " & user_name & ":" & pass_word & " " & quoted form of |source|
end curl_download
on curl_upload(|source|, dest)
do shell script "curl " & quoted form of dest & " -u " & user_name & ":" & pass_word & " -T " & quoted form of |source|
end curl_upload