Batch file to upload .txt to FTP

后端 未结 4 452
情歌与酒
情歌与酒 2020-12-03 06:15

I have setup a separate FTP account for this.

Here is the info:

FTP Username: ahk@proflightsimulatoreview.com
FTP Server: ftp.proflightsimulatorevie         


        
相关标签:
4条回答
  • 2020-12-03 06:18

    I just put HELLO.TXT in your ftp root by;

    1. Saving this as MYFTP.bat:

    @echo off
    echo user ahk@proflightsimulatoreview.com> ftpcmd.dat
    echo ahktest>> ftpcmd.dat
    echo put %1>> ftpcmd.dat
    echo quit>> ftpcmd.dat
    ftp -n -s:ftpcmd.dat ftp.proflightsimulatoreview.com
    del ftpcmd.dat
    

    2. From the command line, in the same directory as MYFTP.BAT, running;

    MYFTP.BAT c:\temp\hello.txt
    

    result

    220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
    220-You are user number 2 of 50 allowed.
    220-Local time is now 05:17. Server port: 21.
    220 You will be disconnected after 15 minutes of inactivity.
    ftp> user ahk@proflightsimulatoreview.com
    331 User ahk@proflightsimulatoreview.com OK. Password required
    
    230-OK. Current restricted directory is /
    230 0 Kbytes used (0%) - authorized: 51200 Kb
    ftp> put hello.txt
    200 PORT command successful
    150 Connecting to port 59363
    226-0 Kbytes used (0%) - authorized: 51200 Kb
    226-File successfully transferred
    226 0.563 seconds (measured here), 14.20 bytes per second
    ftp: 8 bytes sent in 0.34Seconds 0.02Kbytes/sec.
    ftp> quit
    221-Goodbye. You uploaded 1 and downloaded 0 kbytes.
    221 Logout.
    
    0 讨论(0)
  • 2020-12-03 06:25

    The easy way to upload to server is make a script file :
    Code :

    (
    echo USERNAME
    echo PASSWORD
    echo asc
    echo put C:\Users\Kyle\Desktop\ftptest\thetest.txt
    echo quit
    )>temp.txt
    ftp SERVER_DOAMIN -s:temp.txt
    del temp.txt /q >nul
    


    So, the USERNAME is a username, and PASSWORD is a password, SERVER_DOMAIN is a server domain (not ftp:// at the top)

    0 讨论(0)
  • 2020-12-03 06:41

    I did it like that:

    1st bat:

    startupload.bat
    ftp -i -s:upload.bat
    

    2nd bat: upload.bat :

    open ftp.yourserver.com
    username 
    password 
    cd public_html 
    cd Ftp 
    binary
    put C:\Users\Desktop\something.txt
    bye
    

    you run it by opening startupload.bat (if that doesn't work, open cmd.exe and move startupload.bat in it and hit Enter. It will show you where is problem)

    0 讨论(0)
  • 2020-12-03 06:43

    Create a batch file like this:

    @echo off
    
    echo USERNAME> upload.txt
    echo PASSWORD>> upload.txt
    echo asc>>upload.txt
    echo put UPLOAD_FILE_NAME FTP_PATH_TO_STORE_FILE>> upload.txt
    echo quit >> upload.txt
    
    
    ftp -s:upload.txt SERVER_NAME.COM
    
    del upload.txt
    

    UPLOAD_FILE_NAME : - you can store file to be uploaded in the same directory where the batch file exists or give file name with absoulte path.I.e I need to upload a file called register.exe I should use

    echo put register.exe, If register.exe is exists in the batch directory or echo put d:\myfiles\register.exe, If register.exe is exists in another folder(myfiles folder in d drive)

    FTP_PATH_TO_STORE_FILE:- This is the FTP path where I need to put my file.For example /home/myftpfolder/register.exe

    del upload.txt :- its optional because when executes batch file this upload.txt will stores in the directory with FTP username and password

    If I've my server name is theserver.com then the batch file should be write like

    @echo off
    echo user123> upload.txt
    echo 123TTyyy#>> upload.txt
    echo asc>>upload.txt
    echo put register.exe /home/myfiles/register.exe>> upload.txt
    echo quit >> upload.txt
     ftp -s:upload.txt theserver.com
    del upload.txt
    
    0 讨论(0)
提交回复
热议问题