Topic "batch to download montly files from a linux server"

Author Message
lexxx25

Guest


hello,


we have a engine who generates joblogs on a linuxserver and put them all in a directory. i need those files for a monthly evaluation, so i have to copy them in the beginning of the new month on my windows laptop and run a vbs script to generate a xlms file.

now i try to make this by script.

this is what i have done till now

my batchfile:

@echo on
color f1
title MP14

set CURRENTTIME=%TIME%
set Filename=MP14-%DATE:~3,2%-%DATE:~6,4%
mkdir MP14

c:\"Program Files (x86)"\WinSCP\winscp.exe /console /script=winscp.txt

complete_xml.vbs c:\MP14 c:\%Filename%.xlsx

pause




and the winscp.txt file


option batch on
option confirm off
open sftp://username:password@IP-Adress
get -filemask=*>=2017-02-01<=2017-02-30 /var/opt/logs/* c:\MP14\
close
exit



this works fine,but in this case i have to adjust the filemask each month.

my questing now: is there a filemask to say winscp "copy all files from the last full month?" or do anybody know an other way to fix my problem?

for example:

at the 2th of May i need the Files from April. or at the 5 of June i need the files from May.


thanks for help
Advertisements
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27083
Location: Prague, Czechia
With some approximation, this may do:

get -filemask=*>=%TIMESTAMP-28D#yyyy-mm-01%<%TIMESTAMP#yyyy-mm-01% /var/opt/logs/* c:\MP14\

E.g. on 2017-05-05 the above generates
get -filemask=*>=2017-04-01<2017-05-01 /var/opt/logs/* c:\MP14\

See https://winscp.net/eng/docs/scripting#timestamp
Lexxx25

Guest


Hello Martin,

thanks for your post. I test this, but it didn't work.


option batch on
option confirm off
open sftp://username:password@IP-Adress
get -filemask=*>=%TIMESTAMP-28D#yyyy-mm-01%<%TIMESTAMP#yyyy-mm-01% /var/opt/logs/* c:\MP14\
close
exit



when i run the script with this .txt file, i will get all files started on 28.04.2017 (thats okay, because the engine didn`t work on 29.4 and 30.4) backwards to the oldest file somewhere in 2015. Confused


regards lexxx
Lexxx25

Guest


me again.

strange thinks happens Shocked

i do some more tests, but well, if i use this txt, winscp copy "some" files.. (we have round about 700000 files in that directory-3960 for april 2017). sometimes the script copy 156 files with dates trough the complete year (8 for april 2017). start it again 1 minute later without change anyting on script or directory it copy only 80 files with dates trough the whole year (2 for april 2017). 5 minutes later, without change anything, only 10 files will be copied, all from 2016.


using the .txt

option batch on
option confirm off
open sftp://username:password@IP-Adress
get -filemask=*>=2017-04-01<=2017-04-30 /var/opt/logs/* c:\MP14\
close
exit


3960 from april 2017 will be copied.

do you have any ideas? or is it possible to start the script with date-parameters?


regards
martin◆
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 27083
Location: Prague, Czechia
Please attach a full session log files showing the problem for at least two consecutive runs (using the latest version of WinSCP). Include your description of the tests.

To generate the session log file, use /log=path_to_log_file command-line argument. Submit the log with your post as an attachment. Note that passwords and passphrases not stored in the log. You may want to remove other data you consider sensitive though, such as host names, IP addresses, account names or file names (unless they are relevant to the problem). If you do not want to post the log publicly, you can mark the attachment as private.
Lexxx25

Guest


Hello Martin,

well, after using the aktuell version of WinSCP and after some restarts of both engines, the script works perfekt.

thank you very much for your help.


Regards Lexxx
Advertisements

You can post new topics in this forum

Search

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