I had been of the opinion which i could put any executable enter in the cgi-bin
directory of Apache and also have it be utilized for a CGI script. Particularly, if I've got a C# program
static class TestProg
{
static void Main(string[] args)
{
Console.Write("Content-type: text/plain\r\n\r\n");
Console.WriteLine("Arguments:");
foreach (string arg in args)
Console.WriteLine(arg);
}
}
after which visit http://example.com/cgi-bin/TestProg?hello=kitty&goodbye=world
then your query string hello=kitty&goodbye=world
could be passed because the first parameter to primary, so my page need to look like
Arguments:
hello=kitty&goodbye=world
Regrettably, none of my query parameters are becoming passed the page loads and merely prints Arguments:
without a penny following it.
So how do you get my query parameters passed for this program?
It's been a very long time since I have labored with CGI and Apache, but when From the properly, the query string is definitely an atmosphere variable in Apache. In C#, you can observe the atmosphere with System.Atmosphere.GetEnvironmentVariables. I haven't any released paperwork to back me up, but I'd try that out first and find out.
Arguments aren't handed down the command line - rather, apache sets atmosphere variables prior to the cgi program is known as (http://httpd.apache.org/docs/2.0/howto/cgi.html#behindscenes).
You have access to the atmosphere variable 'QUERY_STRING' which consists of the written text from the query string.
String queryString = System.Environment.GetEnvironmentVariable("QUERY_STRING");
You'll then have to parse queryString yourself.
Publish data, however, is passed over STDIN, so you will have to use Console.Directly into process it.