update findValue

This commit is contained in:
Joseph Le 2023-11-23 20:21:14 +11:00
parent 6022621b44
commit ee14dbda74
2 changed files with 10 additions and 15 deletions

View File

@ -11,7 +11,7 @@ const ListLog = () => {
const [value, setValue] = useState("");
const getListFile = async () => {
try {
const res = await axios.get(getListLog);
const res = await axios.get(getListLog,{value: value});
setListFile(res.data);
setStatus(res.status);
} catch (error) {

View File

@ -30,7 +30,8 @@ import { sendDeviceInfora } from "App/utils/sendDeviceInfor";
import InfoDevice from "App/Models/InfoDevice";
import LogReport from "App/Models/LogReport";
import Cache from "@ioc:Kaperskyguru/Adonis-Cache";
import { exec } from 'child_process';
const util = require('util');
const exec = util.promisify(require('child_process').exec);
runtimeCheckLogs(Env.get("FOLDER_LOGS"));
@ -179,23 +180,17 @@ Route.post("/api/private-log/readFile", async ({ request, response }) => {
Route.post("/api/find-value", async ({ request, response }) => {
try {
let result = "";
let value = request.all().value;
console.log("value ", value)
const { value } = request.all();
exec("grep -nr "+value+" /home/logs", (error, stdout, stderr) => {
if (error) {
// console.error(`Error executing command: ${error.message}`);
return "Error:"+ error;
}
console.log("stdout ", stdout)
const { stdout, stderr } = await exec(`grep -nr "${value}" /home/logs`);
response.status(300).send("blabla"+JSON.stringify(stdout) );
});
response.status(200).send(JSON.stringify(stdout));
} catch (error) {
console.log(error);
console.error(error);
response.status(500).send(`Error: ${error.message}`);
}
})
});
Route.post("/api/test", async () => {
try {