Question

I need to use WinSCP in my legacy vb6 code. I always used my script like this:

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

Similar script (with little change) always worked for sslftp, psftp, etc.

Now I need to create script to make this WinSCP work but it keeps throwing "host not found error". I'm not even trying the script. I'm trying it on the command window.

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

same ftp works on regular command line 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.

How do I run WinSCP? The documentation doesn't show any such example.

Was it helpful?

Solution

WinSCP defaults to the SFTP protocol on the port 22. If you want to use the FTP, you need to specify that explicitly.

Also username and password come in session URL as part of the open command, not on separate lines. The passive mode is specified using the -passive=on switch.

open ftp://myusername:mypassword@ftp.myserver.com -passive=on

The ascii mode is specified using the -transfer=ascii switch of the put command (though the separate ascii command is also understood for compatibility):

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

It's the exit, not the quit.


See the complete guide for converting Windows FTP script to WinSCP.

You should also read the guide to automating file transfers to FTP server.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top