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 |
rv...@presidio.com<mailto:rv...@presidio.com>
[Future. Built.]<http://www.presidio.com>
Follow us:
[Follow Presidio on Twitter]<http://www.twitter.com/presidio>
From: Vail, Rick
Sent: Tuesday, October 10, 2017 7:04 AM
To: 'python-list@python.org' <python-list@python.org>
Subject: Printing to a file and a terminal at the same time
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
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.
--
https://mail.python.org/mailman/listinfo/python-list