2011-10-29 122 views
9

我已經爲此設置了一個單獨的FTP帳戶。批量文件上傳.txt到FTP

這裏是信息:

FTP Username: [email protected] 
FTP Server: ftp.proflightsimulatoreview.com 
FTP Server Port: 21 
FTP Password: ahktest 

Text file i want to upload: C:\Users\Kyle\Desktop\ftptest\thetest.txt 

請告訴我怎麼用批處理做到這一點。我的理解是你使用FTP命令創建一個單獨的txt文件,然後使用批處理文件來運行它。那麼我一定沒有插入信息的權利,因爲它沒有工作。

所以我在這裏給你的信息。請告訴我如何上傳文本文件。

+4

http://www.howtogeek.com/howto/windows/how-to-automate-ftp-uploads-from-the-windows-command-line/ –

+0

感謝您的鏈接,但我誠實地嘗試了所有這些。我意識到我要求完全勺羹,但我已經認真地嘗試了幾個小時。我給了FTP帳戶信息,以便有人可以幫我填補所有空白,因爲我顯然是做錯了。另外,我不想從命令提示符上傳,我只想運行批處理文件併爲其完成 – hellohellosharp

+0

當您從該站點運行腳本時會發生什麼情況? –

回答

12

我只是把HELLO.TXT放在你的ftp根目錄下;

。保存此爲MYFTP.bat

@echo off 
echo user [email protected]> 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 

。從命令行中,在與MYFTP.BAT相同的目錄中運行;

MYFTP.BAT c:\temp\hello.txt 

結果

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 [email protected] 
331 User [email protected] 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

非常感謝答覆...它似乎沒有正常工作。我打開了一個命令提示符,鍵入cd C:\ Users \ Kyle \ Desktop \ ftptest \進入正確的目錄,然後鍵入FTP.bat C:\ Users \ Kyle \ Desktop \ ftptest \ thetest.txt 似乎卡住...沒有其他事情發生:( – hellohellosharp

+0

它正在使ftpcmd.dat文件,所以我知道它有點工作。所以令人沮喪: – hellohellosharp

+0

嘗試臨時禁用Windows防火牆 –

3

我做了這樣的:

1蝙蝠:

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

第二蝙蝠: upload.bat:

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

你運行它打開startupload.bat(如果這不起作用,打開cmd.exe並在其中移動startupload.bat並按Enter鍵。在批處理文件存在,你可以存儲文件在同一目錄下上傳或給文件名以 - :它會告訴你在哪裏的問題)

0

創建一個批處理文件是這樣的:

@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 absoulte path.Ie我需要上傳一個名爲register.exe文件,我應該使用

echo put register.exe,如果register.exe是在批目錄中存在或 回聲把d:\ myfiles文件\ register.exe,如果register.exe是在另一個文件夾中存在( myfiles文件夾在d驅動器中)

FTP_PATH_TO_STORE_FILE: - 這是我需要放置我的文件的FTP路徑。例如/ home/myftpfolder/register。EXE

del upload.txt: - 其可選的,因爲當執行批處理文件,這upload.txt將與FTP用戶名和密碼的目錄存儲

如果我有我的服務器名是theserver.com然後批處理文件應該寫這樣

@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

最簡單的方式上傳到服務器是做一個腳本文件:
代碼:

(
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 


因此,用戶名是用戶名和密碼是一個密碼,SERVER_DOMAIN是服務器域名(不FTP://在頂部)