<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python - My first script in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/python-my-first-script/m-p/3698548#M1797</link>
    <description>&lt;P&gt;Hello Guys,&lt;BR /&gt;&lt;BR /&gt;I created script which executes few outputs on Cisco Routers.&lt;/P&gt;
&lt;P&gt;Script is working fine , it logs to device&amp;nbsp; &amp;nbsp;and executes commands.&lt;/P&gt;
&lt;P&gt;But I don't know how force Python to save those outputs to Text Document.&lt;BR /&gt;Please help.&lt;/P&gt;
&lt;PRE&gt;import getpass
import sys
import telnetlib

print ("Script starts")

HOST = "71.61.14.36"

tn = telnetlib.Telnet(HOST, "33153",)
print ("Telnetting to device")

tn2 = telnetlib.Telnet(HOST, "33154",)
print ("Telnetting to device")


print ("Executing commands")
tn.write("\n\n\n\n")
tn.write("\n\n\n\n")
tn.write("enable\n")
tn.write("show ip interface brief\n")
tn.write("show interfaces description\n")


print ("Executing commands")
tn2.write("\n\n\n\n")
tn2.write("\n\n\n\n")
tn2.write("enable\n")
tn2.write("show ip interface brief\n")
tn2.write("show interfaces description\n")
tn2.close()&lt;/PRE&gt;</description>
    <pubDate>Fri, 31 Aug 2018 09:35:12 GMT</pubDate>
    <dc:creator>Ciscomania</dc:creator>
    <dc:date>2018-08-31T09:35:12Z</dc:date>
    <item>
      <title>Python - My first script</title>
      <link>https://community.cisco.com/t5/controllers/python-my-first-script/m-p/3698548#M1797</link>
      <description>&lt;P&gt;Hello Guys,&lt;BR /&gt;&lt;BR /&gt;I created script which executes few outputs on Cisco Routers.&lt;/P&gt;
&lt;P&gt;Script is working fine , it logs to device&amp;nbsp; &amp;nbsp;and executes commands.&lt;/P&gt;
&lt;P&gt;But I don't know how force Python to save those outputs to Text Document.&lt;BR /&gt;Please help.&lt;/P&gt;
&lt;PRE&gt;import getpass
import sys
import telnetlib

print ("Script starts")

HOST = "71.61.14.36"

tn = telnetlib.Telnet(HOST, "33153",)
print ("Telnetting to device")

tn2 = telnetlib.Telnet(HOST, "33154",)
print ("Telnetting to device")


print ("Executing commands")
tn.write("\n\n\n\n")
tn.write("\n\n\n\n")
tn.write("enable\n")
tn.write("show ip interface brief\n")
tn.write("show interfaces description\n")


print ("Executing commands")
tn2.write("\n\n\n\n")
tn2.write("\n\n\n\n")
tn2.write("enable\n")
tn2.write("show ip interface brief\n")
tn2.write("show interfaces description\n")
tn2.close()&lt;/PRE&gt;</description>
      <pubDate>Fri, 31 Aug 2018 09:35:12 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/python-my-first-script/m-p/3698548#M1797</guid>
      <dc:creator>Ciscomania</dc:creator>
      <dc:date>2018-08-31T09:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: Python - My first script</title>
      <link>https://community.cisco.com/t5/controllers/python-my-first-script/m-p/3698613#M1798</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;
&lt;P&gt;Without adding anything to your script why don't you just pipe the output to a text file:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;# python myscript.py &amp;gt; some_text_file.txt&lt;/PRE&gt;
&lt;P&gt;cheers,&lt;/P&gt;
&lt;P&gt;Seb.&lt;/P&gt;</description>
      <pubDate>Fri, 31 Aug 2018 10:32:21 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/python-my-first-script/m-p/3698613#M1798</guid>
      <dc:creator>Seb Rupik</dc:creator>
      <dc:date>2018-08-31T10:32:21Z</dc:date>
    </item>
  </channel>
</rss>

