views:

39

answers:

1

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:

  • Script 1; 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) Script 2 via a socket.

  • Script 2; performs the system calls, passing back output to the Ajax script for output via the socket.

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!

Thanks :)


Edit: 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 (http://sourceforge.net/projects/ajaxphpterm/)

The problem is that, I'm trying to find a method that permits interaction with shell scripts. If a script prompts Press any key to continue, or Select option [x], using AjaxPHPTerm, it just hangs or drops out of the shell script.

That's why I started thinking sockets, or streams; some way of forming a direct I/O stream to the system calls.

A: 

Http is stateless and AJAX, sockets or any other technology based on pages generated by server will not change it magically. Whatever tricks You would use, it will be not efficient and simply not worth the effort (In my opinion at least).

smentek
I can understand the drawback of using the technologies I've described, and perhaps it'd be favorable to write an applet. However, I suppose my real question is; is it possible to create a direct I/O stream to a system call in PHP, providing the ability to communicate with the call mid-execution?
TomcatExodus