I want to download a log file daily from a linux server (/opt/logs/Reports/2022-07-19_Hourly.log) to my windows laptop. Linux server has enabled both scp and ssh. As im not much familiar with scripting I just need to write a small script to automate this process with a small bat file or something. Also need to download the log file to the location where the bat file is executing from. eg: If im inside a folder in the desktop and running the script then the log file also should download for the same folder. Log file location is /opt/logs/Reports/2022-07-19_Hourly.log and the date should be the yesterdays date and the script will be running in the next day. In simply the date should be changed to the previous date. If anyone can help me it would be great. Thank you.
CodePudding user response:
with c# you can code a small app that will run on windows system and download the file using sftp https://www.c-sharpcorner.com/blogs/sftp-file-upload-with-c-sharp-application this is an example of how to code the sftp client.
CodePudding user response:
Scripting in pure Windows is a pain, IMO. If I were you I'd either install cygwin or install WSL, and use a unix script to use scp to copy it down. You can even use cron to automate it if you want. Then your local windows machine will be close enough to a UNIX machine.