I would like to download a file on an ftp site using curl and then move then file on the remote site to another folder i.e. Downloaded so that when I list the directory again I don’t see the downloaded files. Can anyone point in the right direction please? Here’s what I have already:
set fileToDownload to "LMB3006.pdf"
set filesList to every paragraph of (do shell script "curl -l -u username:password [url=ftp://www.theAddress.com/site783/)]ftp://www.theAddress.com/site783/")[/url]
if fileToDownload is in filesList then
do shell script "cd ~/Desktop; curl -O ftp://username:password@wwwtheAddress.com/site783/" & fileToDownload
end if
begin
ftp = Net::FTP::new(host, username, password)
ftp.chdir(download_directory)
ftp.nlst.each do |file|
next if file =~ /^./ # skip dot files
ftp.getbinaryfile(file)
ftp.delete(file)
ftp.chdir(destination_directory)
ftp.putbinaryfile(file)
end
rescue Net::FTPTempError
puts “No files to download”
ensure
ftp.close
end
begin
ftp = Net::FTP::new(host, username, password)
ftp.chdir(download_directory)
files = ftp.nlst
if files.include?(filename)
ftp.getbinaryfile(filename)
ftp.delete(filename)
ftp.chdir(destination_directory)
ftp.putbinaryfile(filename)
end
rescue Net::FTPTempError
puts “No files to download”
ensure
ftp.close
end
And call it like so.
set rubyScript to "ruby /Users/me/Documents/Ruby/filetest.rb" & space & "filename.png"