tags:

views:

36

answers:

3

Hi, I've wrote CGI script for www.

This script expects two parameters through GET method, multiply these numbers and write result into the file.

mult.cgi?m=1&n=2

But now I want to use this script from console too. I'tried something like

./mult.cgi?m=1&n=2

But it didnt work, how can I send parameters to script?

thanks.

A: 

It acts out like a perl script. (correct me if I'm wrong here)

So if you want to run it via the console:

perl mult.cgi 1 2

as for the parameters, you need to convert it to: $ARGV[1] and $ARGV[2]..

NOTE $ARGV[0] is the cgi script (filename) in this case.

Also, you might be required to put: #!/usr/bin/perl at the very top of the cgi script.

Ruel
Its script written in C language.
Meloun
Oh, sorry. Well atleast you should've tagged `c` in your question, or mentioned it. Sorry but only CGI/Perl scripts can be run from the console (correct me if i'm wrong).
Ruel
yes, sorry about that.
Meloun
+4  A: 
QUERY_STRING="m=2&n=4" ./mult.cgi 
Meloun
Do you need a semi?
Lou Franco
No, that syntax sets the variable just for the child process.
Gaius
A: 

You could try:

telnet hostname 80
GET /path/to/script/mult.cgi?m=1&n=2

Which emulates a port 80 (www) connection to the server and executes the script with given parameters.

matthewh