title: Raspberry Pi: how to send serial command using Ethernet?
body: <p>I have a python script, which will start cherrypy webserver when run in the terminal. In the script, i use pyserial by importing <code>serial</code>, then i open up the port /dev/ttyAMA0 and i can send any serial commands.</p>
  
  <pre><code> @cherrypy.expose
   def login (self, **data):
      passcode = data.get("passcode", None)
      print "logging in using passcode %s"%passcode ,type(passcode)
  
      import serial
      import time
      #open connection
      serialport=serial.Serial ("/dev/ttyAMA0", 9600, timeout=0.5)
      #write in user sign in code
      serialport.write("\x03LI%s\x0D"%passcode)
      #get reply 
      reply=serialport.readlines(1)
      print reply, type(reply)
  </code></pre>
  
  <p>However, since there is an Ethernet port and i can send the serial command to that similar device using Netcat, how can i let this script to send commands through the ethernet port instead of the serial port? What should i change?</p>
  
  <p>sorry but i'm really clueless on how to do this. i've searched through google and i can't find answers. :(</p>