Using variables in ftp connection by cmd

后端 未结 3 1575
逝去的感伤
逝去的感伤 2021-01-07 00:55

How I can use variables in ftp? This is what have i done: file a.bat:

set file=test ftp -s:b.txt IP

file b.txt

user password get %

3条回答
  •  太阳男子
    2021-01-07 01:39

    This an example for uploading mutiple files:

    @echo off
    Title Multiple file Upload by Hackoo on adrive
    Color 0A
    ::****** Settings for FTP ************
    Set FTPSERVER=ftp.adrive.com
    Set USER=Your Login
    Set Password=Your Password
    Set LocalFolder=C:\Hackoo
    Set RemoteFolder=/backupFolder
    ::************************************
    ::--- FTP commands below here ---
    > ft.do echo Open %FTPSERVER%
    >> ft.do echo %USER%
    >> ft.do echo %Password%
    >> ft.do echo prompt n
    >> ft.do echo bin
    >> ft.do echo lcd %LocalFolder%
    >> ft.do echo MkDir %RemoteFolder%
    >> ft.do echo cd %RemoteFolder%
    >> ft.do echo mput "*.*"
    >> ft.do echo disconnect
    >> ft.do echo bye
    ::************************************
    ftp -s:ft.do
    del ft.do
    Pause
    

    This an example in batch just for testing that can list only files from a folder located on a public ftp server like ftp.microsoft.com in order to create a list.txt file to download it after, so give a try and tell us the result.

    @echo off
    mode con cols=85 lines=22 & Color A
    ::***********************************
    Set FTPSERVER=ftp.microsoft.com
    Title Lister les fichiers et les dossiers sur un serveur FTP (%FTPSERVER%) by Hackoo
    Set USER=anonymous
    Set Password=anonymous@anonymous.com
    Set DossierFTP=/bussys/winsock/winsock2/
    Set DownloadFolder=winsock2
    ::*******************************************************
    Goto Lister
    :Lister
    > ft.do echo Open %FTPSERVER%
    >> ft.do echo %USER%
    >> ft.do echo %Password%
    >> ft.do echo prompt n
    >> ft.do echo bin
    >> ft.do echo cd %DossierFTP%
    >> ft.do echo ls -h TLIST.txt
    >> ft.do echo bye
    ftp -s:ft.do
    del ft.do
    CLS
    Color 9B
    echo Download la liste
    pause
    Goto Download
    ::*********************************************************
    :Download
    > ft.do echo Open %FTPSERVER%
    >> ft.do echo %USER%
    >> ft.do echo %Password%
    >> ft.do echo prompt n
    >> ft.do echo bin
    >> ft.do echo cd %DossierFTP%
    for /F %%f in (TLIST.txt) do ( >> ft.do echo get %%f) 
    >> ft.do echo bye
    ftp -s:ft.do
    del ft.do
    CLS
    Color 9A
    pause
    echo Deplacer la liste
    Goto Deplacer
    ::*********************************************************
    :Deplacer
    Set Source=%~dp0
    Set Destination=%Source%%DownloadFolder%
    if not exist %DownloadFolder% MD %DownloadFolder%
    for /F %%f in (TLIST.txt) do (move "%Source%%%f" "%Destination%")
    pause
    

提交回复
热议问题