|
Answer» This script runs under Powershell Windows, USES Curl and I made an attempt at a Powershell version of the Blat command line:
Code: [Select]$url = "url.txt" $not_ok_url = "not_ok_url.txt" $work = "response.txt"
[regex] $regex = @" (?smi)(.*200\sOK) "@
if ( Test-Path $not_ok_url ) { REMOVE-Item $not_ok_url }
Get-Content $url | foreach { $site = $_ Start-Process -FilePath "curl.exe" -ArgumentList "-I -s $_" -NoNewWindow -RedirectStandardOutput $work -Wait $response = Get-Content $work -Raw if ( $response -match $regex) { Write-Output "$site ... OK" } else { Write-Output "$site ... NOK" ("-" * 75) | Out-File -FilePath $not_ok_url -Append -encoding ascii $site | Out-File -FilePath $not_ok_url -Append -encoding ascii ("-" * 75) | Out-File -FilePath $not_ok_url -Append -encoding ascii $response | Out-File -FilePath $not_ok_url -Append -encoding ascii } if ( Test-Path $work ) { Remove-Item $work } }
# if ( Test-Path($not_ok_url) ) { # $sender = # $log = # $smtp = # Start-Process -FilePath "blat.exe" -ArgumentList "$sender -subject 'URLs DOWN STATUS' -body 'please check the attachment for the Application DOWN error logs' $smtp -attach 'C:\Not_OK_URL.txt' $log -to '[email protected]' # }
You can tweak the paths at the top of the script. The Blat section is commented out but if remove the COMMENT marks (#) and fill in the values for the variables, it just might work.
|