Printing to a file and a terminal at the same time

Vail, Rick rvail at presidio.com
Tue Oct 10 12:00:53 EDT 2017


I have a script for Cisco devices that will do configuration or any CLI command.  What I would like to do is print the output to my terminal(windows) and to a file. I can come up with stdout parameters
To print to a file but not to the screen and when I remove the stdout part it prints to the screen only.

This prints to a file
filename  = open("outputfile",'w')
sys.stdout = filename
print ("Anything printed will go to the output file")

Remove the above and it prints to the terminal, help



Rick Vail | Network Engineer
Presidio (NASDAQ: PSDO) | www.presidio.com<http://www.presidio.com>
12272 Hancock St, Carmel, IN 46032
D: 317.428.6399 | C: 317.847.0493 | rvail at presidio.com<mailto:rvail at presidio.com>



[Future. Built.]<http://www.presidio.com>


Follow us:

[Follow Presidio on Twitter]<http://www.twitter.com/presidio>





This message w/attachments (message) is intended solely for the use of the intended recipient(s) and may contain information that is privileged, confidential or proprietary. If you are not an intended recipient, please notify the sender, and then please delete and destroy all copies and attachments. Please be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this message is prohibited.


More information about the Python-list mailing list