I guess I need to redirect stdout, but I'm a total beginner, and I
haven't been able to find out from the tutorials how to do this.
You can't with os.system; use subprocess module instead.
I have since found that commands will do it too, eg,
(status, txt) = commands.getstatusoutput('whoami')
or txt = commands.getoutput('whoami')