I have the following script (shown below shortened and excerpted with only the relevant segments) using Nodemailer for NodeJS to e-mail the results of a daily AV scan with a variety of system information embedded.
const nodemailer = require("nodemailer")l
const os = require("os");
var hostname = os.hostname();
var timestamp = Date.now();
// What I need to fill
function getNthLineOfLogFile() {}
var log-file = getNthLineOfLogFile();
...
...
let message = {
to: "example@email.com",
subject: 'AV Update for Today',
text: 'AV Update' + Date.now(),
html:
<b>Date:</b> ${timestamp} <br>
<b>IP Address:</b> ${ip} <br>
<b>Hostname:</b> ${hostname} <br>
<b>Verdict:</b> ${log-file} <br>
For the Verdict: ${log-file}
I need to pull the entire 2nd to last line of a text file that's generated by my AV scan (it will always be the 2nd to last line) with the function getNthLineOfLogFile()
and save the value of that string to var log-file
.
The string in the text file looks like "Infected Files: >Number<"
I'm lost as to how to solve this obstacle any help would be appreciated.