0

"Fetching data from server by FTP command" is not a problem .But if I like to fetch the today's file from the server, whose name is like (BACKUP20141210) and if it presents in a folder with previous dated backup files like (BACKUP20141209, BACKUP20141208, ...), what kind of FTP script is suitable here? Here, I share my BAT FTP script

open myftp.myserver.com
myusername
mypassword
lcd "c:\myfolder"
cd webfolder
for /f "tokens=2-4 delims=/ " %%a in ('echo %date%') do echo get myfile%%a%%b%%c

But I get an "Invalid command" response with the

"for /f "tokens=2-4 delims=/ " %%a in ('echo %date%') do echo get myfile%%a%%b%%c" 

line, and it stops.

Can anyone suggest any relative answer of it. Is there any option to fetch file from server(LINUX) to client by command, not by using FILEZILLA or SFTP, etc. Actually I need a automatic process, will continue on daily basis.

2 Answers 2

0

Unless you have a clever FTP client - that is a scriptable one, for ... is not going to work - it has to be interpreted by a command interpreter. You can however call the FTP client from a script with appropriate parameters.

That said, your script is a Windows cmd.exe batch file, so asking on UNIX & Linux SE is probably not the best idea - SuperUser might be a better place.

-1

Have you tried using mget with appropriate wildcards, like mget *.* ? Alternately consider a non FTP solution like scp or rsync.

1
  • OP mentioned he needed a specific file
    – peterph
    Jan 13, 2015 at 11:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .