Meloun
Meloun

Reputation: 15059

how to run CGI script with parameters from console

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.

Upvotes: 3

Views: 8000

Answers (3)

Matt Healy
Matt Healy

Reputation: 18531

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.

Upvotes: 0

Meloun
Meloun

Reputation: 15059

QUERY_STRING="m=2&n=4" ./mult.cgi 

Upvotes: 13

Ruel
Ruel

Reputation: 15780

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.

Upvotes: 0

Related Questions