title: Send telnet command in python
body: <p>I'm trying to send command in tetnet but it's not working. i tried different code find in this forum but no one works. it's for rebooting a device. i'm using python 3.6.     </p>
  
  <pre><code>import telnetlib
  
  host = "192.168.1.0"
  port = 23
  timeout = 100
  
  session = telnetlib.Telnet(host, port, timeout)
  session.write("administrator\n").encode('ascii')
  session.write("password\n").encode('ascii')
  session.write("reboot\n").encode('ascii')
  </code></pre>