chop off the stream redirection portion of a command

The nested string manipulation is ugly, but no worse than a bunch of
temporary variables.
create xml for stdout redirection if necessary