@echo off setlocal enabledelayedexpansion REM Define variables for log monitoring set…
- User
@echo off setlocal enabledelayedexpansion
REM Define variables for log monitoring set "LOCAL_LOG=%~dp0filelog.log" set "KEYWORDS_FILE=%~dp0keywords.txt"
:: Monitor local log file with PowerShell cls & echo Waiting for Log plink -ssh -pw 12345678 noname@localhost "tail -f log.log" | powershell -NoProfile -ExecutionPolicy Bypass -Command ^ "_ -match '\S' }; " ^ "Get-Content -Path '%LOCAL_LOG%' -Wait -Tail 10 | ForEach-Object { " ^ "_.Trim(); " ^ "if (-not [string]::IsNullOrEmpty(line -ne '-1') { " ^ "line -split ' '; " ^ "if (secondWord = matches = secondWord -ieq matches) { " ^ "if (line" -ForegroundColor Red; " ^ "} elseif (line" -ForegroundColor Green; " ^ "secondWord.mp3"; " ^ "cmd /c msg %username% /time:5 "keyword") { " ^ "cmd /c ffplay "null | Out-Null; " ^ "} " ^ "} " ^ "} " ^ "} " ^ "} " ^ "}"
- Assistant
- User
Access granted. Press Return to begin session. You cannot call a method on a null-valued expression. At line:1 char:120
- ... ject { _ -match '\S' }; ForEach-Object { line = $_.Trim(); if (- ...
-
~~~~~~~~~~~~~~~~~- CategoryInfo : InvalidOperation: (:) [], RuntimeException
- FullyQualifiedErrorId : InvokeMethodOnNull
- Assistant
- User
no output
- Assistant
- User
@echo off setlocal enabledelayedexpansion
REM Define variable for keywords set "KEYWORDS_FILE=%~dp0keywords.txt"
:: Monitor log file remotely via plink and process the output with PowerShell cls & echo Waiting for Log...
:: Make simulation of the log file for testing purposes plink -ssh -pw 12345678 noname@localhost "while true; do echo 'START B_HO_DCAVA01' >> log.log; sleep 1; done" &
plink -ssh -pw 12345678 noname@localhost "tail -f log.log" | powershell -NoProfile -ExecutionPolicy Bypass -Command ^ "_ -match '\S' }; " ^ "while (line = [Console]::In.ReadLine(); " ^ "if (line -ne '-1') { " ^ "Write-Host "words = words.Count -gt 1) { " ^ "words[1]; " ^ "keywords | Where-Object { _ }; " ^ "if (line -like 'START*') { " ^ "Write-Host "line -like 'END*') { " ^ "Write-Host "keyword = "env:USERNAME /time:5 "keyword") { " ^ "cmd /c ffplay "null | Out-Null; " ^ "} " ^ "} " ^ "} " ^ "} " ^ "} " ^ "}"
- Assistant
- User
how to stop :: Start a background process to simulate the log file (this requires that your remote machine supports bash commands) start "" plink -ssh -pw 12345678 noname@localhost "while true; do echo 'START B_HO_DCAVA01' >> log.log; sleep 1; done"
- Assistant
- User
plink -ssh -pw 12345678 noname@localhost "while true; do echo 'START B_HO_DCAVA01' >> log.log; sleep 1; done" &
plink -ssh -pw 12345678 noname@localhost "tail -f log.log" | powershell -NoProfile -ExecutionPolicy Bypass -Command ^
can i use like this
- Assistant
- User
how to remark in powershell
- Assistant
In PowerShell, comments can be written in two ways:
- User
"#cmd /c msg env:USERNAME /time:5 \"keyword"; " ^
- Assistant