CA-121503 - Make use of rc and stderr when appropriate.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Fix up tabs vs spaces
Use begin/end blocks correctly.
Merge pull request #25 from andyhhp/ca-121503

CA-121503 - Make use of rc and stderr in the case of an error