Reputation: 110113
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(...)
Upvotes: 1
Views: 126
Reputation: 414149
You could specify the file as stdout
parameter:
with open(PATH, 'wb') as log_file:
subprocess.check_call(cmd, stdout=log_file)
The output of cmd
is written to log_file
.
Upvotes: 3
Reputation: 7469
What about using the redirect command (in on unix)?
your_python.py > /path/to/transporter_log.txt
Upvotes: 0