copied from backup scripts

Contains stuff for regular "output" as well as "error" output.  Not very sophisticated though...