FTP : Get the latest file from LINUX to Windows using Batch script

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
miaka_1012
Posts: 1
Joined: 17 Jul 2016 18:26

FTP : Get the latest file from LINUX to Windows using Batch script

#1 Post by miaka_1012 » 17 Jul 2016 18:48

Hi Everyone,

I need your help.

I want to create a batch script that will get the specific latest file from linux and put that onto specified Windows directory:

I want simple code as much as possible
So far, I have this code:

1 lcd $DESTINATION_DIR
2 FTP #IP
3 #username
4 #password
5 cd $source_dir
6 ascii
7 get `ls latest*.csv | tail 1`
8 bye

But I got error in #7. I dont know if my idea is simple as this.. need your expertise

Thank you in advance.

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: FTP : Get the latest file from LINUX to Windows using Batch script

#2 Post by foxidrive » 18 Jul 2016 04:30

miaka_1012 wrote:I want to create a batch script that will get the specific latest file from linux and put that onto specified Windows directory:

So far, I have this code:

1 lcd $DESTINATION_DIR
2 FTP #IP
3 #username
4 #password
5 cd $source_dir
6 ascii
7 get `ls latest*.csv | tail 1`
8 bye

But I got error in #7. I dont know if my idea is simple as this.. need your expertise


Your code is a mixture of batch files and FTP commands, but mostly FTP commands.
You're asking for the latest file but showing a filename called latest.

It would help if you give accurate details about the task - not password or username or URL though.

See here: viewtopic.php?f=3&t=6108

Post Reply