The appropriate answer depends on many things. Do you want to capture the output? Do you want just the exit code? Do you want to pass extra commands while the program executes?
To answer the last three questions, neither. I read How can I capture STDERR from an external command? That's not what I'm looking for. Notice the print statements in the program. Instead of printing the output, I want to execute the output.