Automation of cygwin through a batch file

In short, we have several servers on which we run perfoologists monitoring every night. My task is to convert these logs to .csv format and send them to my email address.

This bit is already automated with a .sh script written by a former employee.

What I want to automate is to start a batch job after registering perfmon to look at a specific folder and find the last .blg file and run a sh script on it (a script called upload), so I don’t have to log into each server and do it manually .

eg.

download myInitials cd / cygdrive / someLocation / logs / $ latestFile $ .blg

myInitials and location can be hardcoded ... I just don’t know how to find the last file in a folder and automate all this with a batch file.

Any pointers would be very helpful!

@Jeremiah:

Sorry, I probably should have mentioned in my question that servers have been running since 2003 and 2008.

I do not think it would be absolutely necessary to register a notification of a change in a folder. If the log runs from noon to 7 in the morning, the script will run immediately after (you can set the script to run after the perfmon log log completed in the log properties), so the log will by far be the most recent file in the folder anyway.

, .sh csv e-mail, , cygwin upload xx/cygdrive/location/logs/xyz.blg, , RDC.

!

+3
3

script, script Windows, . , cygwin C:

start_cyg.bat

@echo off
set PATH=%PATH%:"C:\Cygwin\bin"

rem bash --login -i

bash "/cygdrive/d/cyg.sh"

cyg.sh

#!/bin/bash

TAIL=`ls -lrt | tail -1`
echo "TAIL:$TAIL"

start_cyg.bat Windows, cyg.sh

+8

, ls -1tr | tail -1 .

+2

-, , , Windows 2 Vista + . concurrency, . , , .

, , . , . , script, .

I think cygwin may even support change notifications through scripts, although I'm not sure. I believe there are linux extensions for this, but I could be wrong.

If it were me, I would just write a small C ++ application to do everything I wanted ... but for you, perhaps some (or most likely not) of the above helps; o.

+1
source

Source: https://habr.com/ru/post/1766920/


All Articles