in reply to How a web server sending data to a CGI perl script ?

a CGI script don't need to concern what the server is, so I believe there must be a standard way to do that.
Indeed there is a standard way to do that: The Common Gateway Interface, usually referred to by its initials, "C.G.I.".

If I understand the question correctly, you're writing a web server and want to be able to call scripts via CGI, but you don't know what the calling side of the interface is supposed to do. If my understanding is correct, then you should probably take a look at the CGI spec, aka RFC 3875 - The Common Gateway Interface (CGI) Version 1.1.

  • Comment on Re: How a web server sending data to a CGI perl script ?

Replies are listed 'Best First'.
Re^2: How a web server sending data to a CGI perl script ?
by exilepanda (Friar) on Jan 21, 2016 at 08:55 UTC
    Um.. Not exactly what I am asking. Say, I fetched a URI from the client wanted "index.pl", then I want to *delegate* the query string , %ENV I've constructed in my server to index.pl for implementation, and I capture the result and return it to the client.

    The meaning I said a CGI script don't need to concern... is that a CGI script can always code like this :

    #!perl print "Content-Type: text/html\n\n"; print $ENV{REMOTE_ADDR};
    The script don't need to care about the server is IIS or Apache...

      It is exactly what you're asking. A server implementing CGI uses %ENV to communicate HTTP headers and other basic values (document_root)

      STDIN is used for the BODY of the HTTP request

      If this doesn't answer your question ... ask a different question please

        In short, "How"?

        I read the RFC recommended,I know what I should prepare (and I already knew) for my script, but the question is how to send it to the script.

        Do I send them via a pipe ? or command line with -??? switches, or what ? As far as web servers I've explored, I notice the only thing that need to tell the server is where the interpreter is (, and associate the application/type with file name extension). So what's the magic between ?