I have a command running in PowerShell, and it will unpredictably error out (whenever the network connection becomes saturated, it errors)
After it errors, it will no longer function as intended, but continue to run. The error is also not printed as an error, just as standard text.
I would like to have the command running in a loop that detects when it errors, then kills it, and restarts it, but I have been unable to find anything about parsing the output of a command in real-time.
For example: foo.ps1
outputs a number every second, but will randomly begin outputting "ERROR: CONNECTION SATURATED" once every second instead. How can I create a loop that detects that, kills the process, and restarts it?
EDIT:
command erroring
This is what the command erroring looks like. As you can see, the error (Warning: ring buffer overflow!!!
) is printed as stdout, not as an error.