I use PowerShell to run a script that runs wgetto retrieve a web page (simple import of the script database) and parses its output (error message or "OK").
I am using the code from the answer to this previous question .
$a = c:\path_to_wget\wget.exe --quiet -O - "http://www.example.com/import_db"
$rc = $a.CompareTo("OK")
exit $rc
When the result of the wget operation is 404 - and wget probably returns an error level of 1 or 127 - I get the following error message from PowerShell:
You cannot call a method on a null-valued expression.
this obviously applies to my function call CompareTo().
However, wget launches and outputs something.
I suspect that wget output to the error console in this case, and this does not fall into my $ a operation.
How can I redirect the error output so that it gets into my script?
, , PowerShell !:)