Copy files from FTP server to local directory?

I want to create a batch file, including the following functions:

  • Connect to FTP server
  • Copying files from there (the "out" directory) to the local directory
  • if successful, then deleting files from the FTP server
  • repeating these steps every 15 minutes.

I have not done this with batch files for so long, so it would be great if you could help me. I know that there is a command ftp, and I know how to connect ( ftp open), but, unfortunately, I do not know how to copy them every 15 minutes.

Many thanks for your help!

+3
source share
5 answers

ftp , . http://support.microsoft.com/kb/96269. ftp,

ftp -i -s:ftpcommands.txt

ftpcommands.txt :

open ftp.myftpsite.com
username
password
bin
cd out
mget *
del *
bye

15 . (at Command Scheduler).

( -i - - prompt off mget. mget , . [ !])

+3

@AAT ftp.exe Windows. , , FTP, NAT. FTPS (FTP TLS/SSL).

, FTP-. , .


, FTP- WinSCP, (.bat):

WinSCP.com /command ^
    "open ftp://username:password@ftp.example.com/" ^
    "get /out/* c:\local\path\" ^
    "exit"

ftp.exe script, WinSCP script.


. FTP-.


( WinSCP)

+1

Windows at, Windows . .

0

(1).bat script. FTP script , , .

SET "FTPFILE=%TEMP%\myftpscript_%RANDOM%.txt"

ECHO>>"%FTPFILE%" open ftp.myftpsite.com
ECHO>>"%FTPFILE%" username
ECHO>>"%FTPFILE%" password
ECHO>>"%FTPFILE%" bin
ECHO>>"%FTPFILE%" cd out
ECHO>>"%FTPFILE%" mget *
ECHO>>"%FTPFILE%" del *
ECHO>>"%FTPFILE%" bye

ftp -i -s:"%FTPFILE%"

IF EXIST "%FTPFILE%" (DEL "%FTPFILE%")

EXIT /B 0
0

crontab:

cd /local_target_directory; lftp -c "mget -E ftp://username:password@ftp.hostname.domain/path/*"
-1

Source: https://habr.com/ru/post/1793551/


All Articles