2013-12-11 33 views
1

我需要在我的遺留vb6代碼中使用WinSCP。我總是用我的劇本是這樣的:如何將Windows FTP腳本轉換爲WinSCP?

open ftp.myserver.com 
myusername 
mypassword 
passive on 
cd myfolder\ 
ascii 
put C:\temp\test.xml test.xml 
close 
quit 

類似的腳本(變化不大)一貫致力於sslftp,PSFTP等

現在我需要創建腳本來使這個工作的WinSCP,但它不斷拋出「主機未找到錯誤」。我甚至沒有嘗試腳本。我正在命令窗口中嘗試它。

winscp> open ftp.myserver.com 
Searching for host... 
Network error: Connection timed out. 

相同的FTP適用於普通FTP命令行:

ftp> open ftp.myserver.com 
Connected to myserver. 
220 Gene6 FTP Server v3.10.0 
User (...): myuser 
331 Password required for myuser 
Password: 
230 User manager logged in. 

如何運行WinSCP賦予?該文檔不顯示任何這樣的例子。

回答

1

WinSCP默認爲端口22上的SFTP協議。如果要使用FTP,則需要明確指定。

此外,用戶名和密碼作爲open command的一部分進入session URL,不在單獨的行中。被動模式是使用-passive=on開關指定的。

open ftp://myusername:[email protected] -passive=on 

使用put command-transfer=ascii開關(雖然也可以理解爲兼容性單獨ascii命令)被指定ASCII碼:

put -transfer=ascii C:\temp\test.xml test.xml 

這是exit,不quit


查看完整的guide for converting Windows FTP script to WinSCP

您還應該閱讀指南automating file transfers to FTP server