如何将Windows FTP脚本转换为WinSCP?

时间:2013-12-11 23:17:28

标签: ftp winscp

我需要在我的旧版vb6代码中使用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 个答案:

答案 0 :(得分:1)

WinSCP默认使用端口22上的SFTP协议。如果要使用FTP,则需要明确指定。

同样,用户名和密码作为session URL的一部分来自open command,而不是单独的行。使用-passive=on开关指定被动模式。

open ftp://myusername:mypassword@ftp.myserver.com -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的指南。