Download files from Unix server using WinSCP with

2020-01-29 18:02发布

问题:

I have program in Unix that generates files 8 files at 8:30 pm everyday.

I need to download the files into my Windows machine after the files are generated using WinSCP.

I can drag and drop those but its time consuming, I need to automate this process.

I cannot use .Net assembly to download those.

I have tried to use the get command, but its throwing error: Not an SCCS file.

Let me know how can I solve this.

--Thanks

回答1:

To automate a task using WinSCP, use its scripting interface from a batch file (e.g. download.bat).

I assume you want to use SFTP, as you are connecting to a *nix server.

The simplest download batch file is like:

winscp.com /log=c:\path\to\log\winscp.log /command ^
    "open sftp://username:password@example.com/ -hostkey=""xxx""" ^
    "get /path/to/file.ext c:\path\to\download\to\" ^
    "exit"

Replace the username, password and example.com with the actual connection details. Get the value of -hostkey switch from your GUI session. Use real paths.

Though it's easier to have WinSCP generate the batch file for you.

For details see a guide to automating file transfers from SFTP server using WinSCP.


Once you have the batch file working, schedule the the batch file execution using Windows scheduler.

See a guide to scheduling file transfers from SFTP server.