Reputation: 21
I have a log from a .bat script that downloads files from two separate WinSCP folders and then deletes the files from WinSCP and downloads them to a specific folder on an azure server. I wanted to only see the date, time, and files of the specific files downloaded from WinSCP to the azure server as opposed to all of the other data in the log. Is there a way to do this? From my own research, I've seen people suggest PowerShell scripts or using the grep command but that won't produce a log I can look back at daily that just specifies the date files were pulled, the time and what specific files were downloaded and deleted from WinSCP?
Log Example:
. 2022-05-20 17:56:56.078 WinSCP Version 5.19.6 (Build 12002 2022-02-22) (OS 10.0.17763 - Windows Server 2019 Datacenter)
. 2022-05-20 17:56:56.079 Configuration: nul
. 2022-05-20 17:56:56.079 Log level: Normal
. 2022-05-20 17:56:56.079 Local account: NA\rustyshakelford01
. 2022-05-20 17:56:56.079 Working directory: C:\SftpScripts
. 2022-05-20 17:56:56.079 Process ID: 18964
. 2022-05-20 17:56:56.094 Ancestor processes: WinSCP, cmd, explorer, ...
. 2022-05-20 17:56:56.095 Command-line: "C:\Program Files (x86)\WinSCP\WinSCP.exe" /console=5.19.6 /consoleinstance=_25988_652 "/log=C:\SftpScripts\Log\WinSCP.log" "/ini=nul" "/command" "open sftp://THR1:***@12.50.9.55/ -hostkey=""ssh-rsa 1024 h/hAIAyM00g7C85w9sSGKlutqsjrCf/ka8ZxD9hPKZw=""" "cd /sftp.DALE.org/usr/RUSTY/835/Test" "lcd ""E:\Raw Client Data Files\THR\Automated Pull Down - Not Processed\835""" "get -delete /sftp.DALE.org/usr/RUSTY/835/Test/*" "exit"
. 2022-05-20 17:56:56.095 Time zone: Current: GMT+0 (Coordinated Universal Time), No DST
The data/lines I would like to pull from the log would say something like:
2022-05-25 20:58:26.195 File: '/sftp.DALE.org/usr/RUSTY/835/From_THR/Send to Rusty Mar 2022 Whole and JV Epic only/TEST_68069NON2022033111220600X_MCDMCD' [2022-05-24T20:24:18.000Z] [1432]
. 2022-05-25 20:58:26.196 Copying "/sftp.DALE.org/usr/RUSTY/835/From_THR/Send to Rusty Mar 2022 Whole and JV Epic only/TEST_68069NON2022033111220600X_MCDMCD" to local directory started.
Which I believe provides an example of a file copied successfully to the correct folder. Hopefully, this provides more insight.
Upvotes: 0
Views: 793
Reputation: 202340
First, I do not see why grep
(or findstr
as suggested by @Stephan) won't work for you.
Anyway, you get the greatest flexibility with XML logging. Use /xmllog
command-line switch. XML log is way less verbose than the session log, yet it includes all information about transfers, and it can be transformed to any format you like.
Upvotes: 1