title: Writing a pseudo terminal in python for a web based ubuntu terminal
body: <p>I am interested in writing a web based terminal which can execute and autocomplete the commands in ubuntu terminal.</p>
  
  <p>I have fiddled with Anyterm <a href="http://www.anyterm.org" rel="nofollow">http://www.anyterm.org</a> which uses ROTE: "a simple C library for VT102 terminal emulation" at the backend server and javascript/html for the terminal ui. The problem was that I couldn't have it open two terminals in the same window.</p>
  
  <p>After doing some research I've decided to write a terminal server/pseudo terminal (whichever is the right terminology) in python which can:</p>
  
  <ul>
  <li>execute commands in ubuntu terminal (such as ls, grep etc...)</li>
  <li>autocomplete the commands (like $gedi (pressed tab) $gedit)</li>
  <li>and have multiple instances of terminal open at the same time (when typed ls in one, the other terminal won't recognize ls as the last command since its another terminal session)</li>
  </ul>
  
  <p>I have found that with <a href="http://docs.python.org/release/3.2.2/library/pty.html#module-pty" rel="nofollow">pty python module</a> I can write a pseudo terminal 
  however I'm new to python and I couldn't even get the example on that page to work. </p>
  
  <p>I'm planning to have the python script serve a http server with the javascript/html terminal ui I would write (this was the main reason I wanted to choose python for this project). Then I want to let the web ui talk to the backend terminal "server" and get the results back to the web ui. </p>
  
  <p>If you could point me in the right direction, maybe tell me which module I should use -if not pty- and give me some ideas on how to write the python pseudo terminal server I would appreciate it.</p>
  
  <p>I know javascript/php and familiar with bash scripting- At this point I could go for a C based or python based backend server, is python right for this project?</p>
  
  <p>Note: I'm planning to write a ui that uses ajax post or get methods to retrieve the terminal output from backend server.</p>