Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

User1981

many thanks!
User1981

Found example code, but it won't let me connect

Hello everyone
I found some example code on the internet, but it won't let me connect to the SFTP.

I've been using FileZilla for SFTP transfers, but I am now in the need for some automated scripting. So I came across WinSCP. Every day I connect to a remote folder and there are just under 100 files. And every day I'm downloading a dozen from there, and that list of files I need varies by day of week. So I want to automate that :)

I found this thread here and then copied the script mentioned in there:
Download a file from SFTP site using VBA

But the shell tells me host "username" does not exist. So something must be wrong in the syntax that I copied from there.

This is my script:
# Connect to the host and login using password
open sftp://user:password.host.com
# Change the remote directory
cd remotetargetpath
# get all the files in the remote directory and download them to a specific local directory
get *example_pattern*.csv localtargetpath
# Close and terminate the session
exit

What am I doing wrong?
I tried the documentation/help on here, searched for the open command, but can't find syntax :(