Score:0

Move files from a remote ftp server to a local

us flag

I need to pull files from an ftp server regularly and have found that I can get the files easily enough using wget

wget -m --user=yyy --password=xxxx ftps://host.com.au

and that works really nicely. The problem is, it obviously leaves the files behind on the remote server and the next time I run the script, it gets them all again.

I saw that wget has a --delete-after flag, which on first glance would seem to be ideal, but, as the man page says, it only deletes local files not remote ones.

Is there a way to achieve this end? It needs to be via ftp unfortunately as I don't have shell access or rsync access to the remote server. Should I be looking at something other than wget?

Appleoddity avatar
ng flag
Why are you using wget instead of an ftp client, which would be more likely to have this feature?
us flag
Good question. I can use filzilla or some such to achieve the outcome I'm after, but, I need to be able to script this so that I can run it from cron each day.
Romeo Ninov avatar
in flag
Have you consider using `lftp`?
us flag
Hi @RomeoNinov can you please change your comment to an answer. I'ts 90% working so I should give you the benefit of status :) All I need to work out is how to have mirror leave the remote directories intact and just remove the files lftp ftp://site.com --user PW --password blah -e "mirror --Remove-source-files --verbose; bye" removes files and directories when its done transferring.
Score:2
in flag

Instead of wget you can try lftp. Command like:

 lftp site.com --user <username> --password <password> -e "mirror --Remove-source-files -v

in this command -e "mirror is used to do a mirror or remote site

--Remove-source remove the source files after download. Be very careful with this command

us flag
Thanks for the answer. As I said in the comment above, --Remove-source does remove the source files which is great, but it also removes the directories in the entire directory tree which is not really what I want it to do, just remove the .csv files in the various directories.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.