Topic "Automation of downloading script"

Author Message
Layton Habson

Guest


I need to download three files everyday at 7:00 a.m. from a remote server, and place them on my desktop (then a sql server job picks them up and inserts into the tables).

When signed-in the remote server, there are 3 folders as follows:

<Folder 1>
<Folder 2>
<Folder 3>

In the <Folder 3>, there are two more folders and six files (three of them are log and the other three are text files). I need to download the ‘txt’ files, which are shown in red color below:

<archive folder>
<old folder>
Abc_<12345>.log
Abc_<12345>.txt
Pqr_<54215>.log
Pqr_<54215>.txt
Xyz_<64524>.log
Xyz_<64524>.txt

Please note that the number <12345> is dynamic and it changes everyday.

To test with one file, I wrote the script to automatize the downloading of the file as below:

/command "option batch abort" "option confirm off" "open sftp://<user>:<password>@<website.com >/<Folder 3>/<abc_*_txt>" "get c:\<local_filename.txt>" "exit"

Since the number part of the file name changes dynamically everyday, I have used ‘*’.

In Windows 7, I have scheduled a task to run the script automatically, and placed the above script in ‘Add arguments (optional)’ field. The ‘Program/script’ field looks as follows: ‘C:\Users\Downloads\winscp571setup.exe’

At the designated time (7:00 a.m) the Windows7 task scheduler is triggering the task. But the task “appear to” run endlessly and not completing the run even after 2 hours (the file being tested is of 6000 bytes. Other files are very huge).

Please help me with the correct script and the steps I need to follow.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25015
Location: Prague, Czechia
There's no red color in your post, so I do not know which files you want to download.

Anyway, the command-line would be like (with WinSCP 5.7.1):

/log="c:\path\winscp.log" /command "open sftp://<user>:<password>@<website.com>" "get ""/Folder 3/*.txt"" ""c:\<local_filename.txt>""" "exit"

Note that I added a /log switch, so that you can inspect the log, if you still have problems.

References:
https://winscp.net/eng/docs/guide_automation
https://winscp.net/eng/docs/guide_schedule
https://winscp.net/eng/docs/scriptcommand_get
https://winscp.net/eng/docs/commandline#logging
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License