batch to download montly files from a linux server

Advertisement

lexxx25
Guest

batch to download montly files from a linux server

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

Reply with quote

Advertisement

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. :?


regards lexxx

Reply with quote

Lexxx25
Guest

me again.

strange thinks happens :shock:

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

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
41,454
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.

Reply with quote

Advertisement

Lexxx25
Guest

Thanks

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

Reply with quote

Advertisement

You can post new topics in this forum