title: PHP CLI + Ajax for web terminal
body: <p>I'm trying to determine the best approach to providing an Ajax based terminal using PHP. I haven't made an attempt at writing it yet but having rolled the idea around, the only way I could see it possible, would be 2 scripts:</p>
  
  <ul>
  <li><p><strong>Script 1</strong>; handles Ajax communication
  between server and client browser. when a
  request is made to use the terminal,
  it connects to (or starts as a service then
  connects to) <em>Script 2</em> via a socket.</p></li>
  <li><p><strong>Script 2</strong>; performs the system calls,
  passing back output to the Ajax
  script for output via the socket.</p></li>
  </ul>
  
  <p>There are multiple holes I can see in this though, and I'm wondering if anyone has created/seen a set of scripts that can perform these tasks? Any insight would be greatly appreciated!</p>
  
  <p>Thanks :)</p>
  
  <hr>
  
  <p><strong>Edit</strong>: I think I was unclear about a few things. I've found a few scripts that imitate terminals, providing nearly the functionality that I'm looking for, such as AjaxPHPTerm (<a href="http://sourceforge.net/projects/ajaxphpterm/" rel="nofollow">http://sourceforge.net/projects/ajaxphpterm/</a>)</p>
  
  <p>The <em>problem</em> is that, I'm trying to find a method that permits interaction with shell scripts. If a script prompts <code>Press any key to continue</code>, or <code>Select option [x]</code>, using AjaxPHPTerm, it just hangs or drops out of the shell script.</p>
  
  <p>That's why I started thinking sockets, or streams; some way of forming a direct I/O stream to the system calls.</p>