Interacting With Another Script

Chris Rebert clp2 at
Wed Mar 10 17:31:06 CET 2010

On Wed, Mar 10, 2010 at 4:32 AM, Victor Subervi <victorsubervi at> wrote:
> Hi;
> There's a program (vpopmail) that has commands which, when called, request
> input ("email address", "password", etc.) from the command line. I would
> like to build a TTW interface for my clients to use that interacts with
> these commands. It's easy enough for me to get the information from a
> script, but how do I input it when these functions keep requesting
> information? I hope I've made myself clear :-}

(assuming TTW = Thru The Web; been a while since I've come across an
unknown, non-new acronym)

[Disclaimer: I know zilch about vpopmail's specifics]

Option A. Check for when the latest output looks prompt-like (e.g.
colon followed by a space; this will be program-specific and possibly
different for vpopmail) and then ask for input. For example:
1. Get new session request from client
2. Run new vpopmail process
3. Wait until prompt detected in process' output
4. Send back webpage with the output and a <form> to answer the prompt
5. Write user's response from form as input to process.
6. If read EOF, send final output back as webpage to client and close
session. Else, GOTO 3
(See also: expect)

Option B. Web pseudo-shell using AJAX. Client polls server for new
output. Client pushes new input to server at any time.
1. Get new session request from client
2. Run new vpopmail process
3. Send back webpage w/ JavaScript code
4.1. Client periodically polls server for new output via AJAX and
displays it when there is some.
4.2. Client has omnipresent <form> that on submission sends an AJAX
request to the server with the given input.
5. If get input message from client, write input to process' stdin. If
get polling message from client, do non-blocking read on the process'
output and respond with the result. If get EOF, inform client on next
poll and then close session.

Option C. The most user-friendly, and in some sense simplest, one.
Figure out the "conversation tree" vpopmail follows. Create a matching
form tree workflow, presenting multiple input fields at once. Run
vpopmail and write the appropriate input to its stdin based on the
form data. Send the output back as a webpage.

[Session management & timeouts in the preceding are left as exercises
for the implementor]

Option D. The Zen option: It seems quite probable that someone's
already written a web frontend for vpopmail
administration/configuration. Just use that. The best software is that
which you don't have to write.

Ironically, I have yet to code a webapp.

More information about the Python-list mailing list