diff --git a/README.md b/README.md index c682ced..f456b4c 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,9 @@ Scripts for remote logging data from ratgdo * Usage: `./ratgdo-logger.sh ` * To capture to a file append the command with: ` > my.log` -## Windows PowerShell -* Usage: `.\ratgdo-logger.ps1 -HostName ` -* To capture to a file append the command with: ` > my.log` - -``` -mbpm3:remote-logging paul$ ./ratgdo-logger.sh 10.0.1.191 +**Example:** +```bash +$ ./ratgdo-logger.sh 10.0.1.191 Pinging 10.0.1.191... ✅ Host 10.0.1.191 is reachable. Checking firmware type... @@ -19,3 +16,8 @@ Checking firmware type... 2025-08-01T12:20:03Z data: [D][ratgdo:229]: Light state=OFF 2025-08-01T12:20:03Z data: [D][ratgdo:235]: Lock state=UNLOCKED 2025-08-01T12:20:03Z data: [D][ratgdo:214]: Learn state=INACTIVE +``` + +## Windows PowerShell +* Usage: `.\ratgdo-logger.ps1 -HostName ` +* To capture to a file append the command with: ` > my.log` diff --git a/ratgdo-logger.ps1 b/ratgdo-logger.ps1 index d75fce2..8f152b2 100644 --- a/ratgdo-logger.ps1 +++ b/ratgdo-logger.ps1 @@ -32,15 +32,15 @@ Write-Host "---" try { $printNextLine = $false - + curl.exe -s --no-buffer $Url | ForEach-Object { if ($printNextLine) { $timestamp = (Get-Date).ToUniversalTime().ToString("s") + "Z" - + # --- THIS IS THE KEY CHANGE --- # Changed Write-Host to Write-Output to enable file redirection. Write-Output "$timestamp $_" - + $printNextLine = $false } if ($_ -eq 'event: log') { @@ -54,4 +54,4 @@ catch { finally { Write-Host "---" Write-Host "Log capture stopped." -} \ No newline at end of file +} diff --git a/ratgdo-logger.sh b/ratgdo-logger.sh index 40f2a38..45b1014 100755 --- a/ratgdo-logger.sh +++ b/ratgdo-logger.sh @@ -45,4 +45,4 @@ curl -s --no-buffer $URL | while IFS= read -r line; do timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") echo "$timestamp $next_line_clean" fi -done \ No newline at end of file +done