Forum

argc/argv are not passed to CGI program

SimonP
28 April 2013, 05:14
Hiawatha version: hiawatha-9.1
Operating System: 2013-02-09-wheezy-raspbian
Platform raspberry p ;-)

I have noticed that there is an old post about this question (and some obvious workarounds)
but i am posting anyway, more because this is a "Hiawatha not functioning as expected ..." rather than a bug.

maybe i have not perfectly understood the cgi mechanics of Hiawatha and maybe this is a feature instead of a bug
anyway i have noticed that command line arguments are not passed to the cgi program by Hiawatha

I have developed (under apache) several applications that rely on command line arguments and
as i am a lazy old programmer i would know if it eventually will be possible to have cmdline arg
passed to cgi ...


How to reproduce:

compile the following code and put the executable into your cgi folder as "bugtest.cgi"

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc,char **argv)
{
int i;

printf("Content-Type: text/html\n\n");
printf("<html><body>\n");

printf("This program will test the data recieved on the URL using GET Requests. <br />");
printf("This program ( %s ) recieved %d arguments <br />\n", argv[0], argc);

for(i=1;i<argc;i++)
{
printf("Argument %d: %s<br />", i, argv[i]);
}
printf ("</body></html>\n");

}


invoke it: .../bugtest.cgi ?this+is+the+data

you will get

This program will test the data recieved on the URL using GET Requests.
This program ( /var/www/cgi-bin/bugtest.cgi ) recieved 1 arguments

Instead of:

This program will test the data recieved on the URL using GET Requests.
This program ( /var/www/cgi-bin/bugtest.cgi ) recieved 5 arguments

Argument 1: this
Argument 2: is
Argument 3: the
Argument 4: data
Hugo Leisink
28 April 2013, 09:44
This is a very bad idea. The feature you describe works on Apache, but a while ago it let to the disclosure of PHP files for certain configuration. Take a look here:

So, sorry, I will not implement this in Hiawatha. An a web application that requires command line arguments has been badly written. Because in a web environment, there is no command line.
SimonP
28 April 2013, 12:51
So this is a feature ;-) ...
I agree 99.9% with you, (maybe a web application that requires "command line arguments" could be well written also ;-) ...)
anyway i do understand the reasons for your choice.
Thank you very much for the ultra prompt reply, let me make you my best compliments for Hiawatha
This topic has been closed.