title: How to use sockets in Lua to telnet?
body: <p>In Lua, I downloaded the LuaSocket library and then am trying to:</p>
  
  <ol>
  <li>Connect using telnet</li>
  <li>Send some commands</li>
  <li>receive output from the commands to parse later</li>
  <li>close telnet</li>
  </ol>
  
  <p>What am I doing wrong with this code that is not making that work?</p>
  
  <pre><code>local socket = require("socket")
  conn = socket.tcp() 
  conn:connect("IP Address",23)
  conn:send("password") 
  conn:send("enable") 
  conn:send("password2") ;; above was all login procedure
  conn:send("sh run interfaces ethernet 16")
  var1 = conn:receive('*l')
  print (var1)
  </code></pre>
  
  <p>I expected this to give me the first line of code printed off by the sh run interfaces ethernet 16 command, but all I get is 2:) 2v sqrt:) sqrt&lt;3... That is, four random symbols that I don't know what they mean.</p>
  
  <p>Any help on what I did wrong here would be greatly appreciated, thanks.</p>
  
  <p>here are those four symbols: <img src="https://i.stack.imgur.com/BYOX1.png" alt="enter image description here"></p>