Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.
edited title
Link
David542
  • 112.2k
  • 211
  • 581
  • 1.1k

Print the outputs Using subprocess to log print statements of a specific command to a log file

Source Link
David542
  • 112.2k
  • 211
  • 581
  • 1.1k

Print the outputs of a specific command to a log file

I am running a Transporter command, which prints a log of what is happening to the prompt.

How would I re-direct all the print statements to a separate file called transporter_log.txt in the same folder as the script is running from? Something like -

log_file = open(PATH, 'w') subprocess.call(shlex.split("/usr/local//iTMSTransporter -m verify...") log_file.write(...)