I am trying to pass arguments to lớn this CGI size (http://www.westegg.com/inflation/) through the URL, so I don"t have khổng lồ manually type them in, và so that I can generate URLs through other means for faster use.

Bạn đang xem: Passing url parameters to a cgi script from the shell

Here is the CGI form code from the site:

Enter the amount of money: Enter the initial year (1800-2008): Enter the final year (1800-2008): I"ve tried passing arguments via the "?" và "&" syntax, but none of these work:

http://www.westegg.com/inflation/infl.cgi?money=1&first=1800&last=1900http://www.westegg.com/inflation/infl.cgi?money="1.00"&first="1800"&last="1900"Thanks for your help :)


Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first)
Notice that the khung uses the POST method, not GET. It"s impossible to just pass the arguments in the URL. There"s a lot of information out there how POST works.



SO I was able to lớn get something similar to lớn work. First, make sure that you"ve got the right parameters and names (you"ve got the variable names apparently). You"ll need to look at the source code of the resultant page, but you need khổng lồ find the variable that executes the form. In my case I was using a search page & the button name was "searchresult
Flag". Try something like:


My parameters were different from yours, but this worked for me.


Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

Please be sure lớn answer the question. Provide details & share your research!

But avoid

Asking for help, clarification, or responding khổng lồ other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Post Your Answer Discard

By clicking “Post Your Answer”, you agree khổng lồ our terms of service và acknowledge you have read our privacy policy.


Company cookie-settings#toggle" class="s-btn s-btn__link py4 js-gps-track -link" data-gps-track="footer.click( location: 2, link: 38 )" data-consent-popup-loader="footer">Cookie Settings
Site thiết kế / hình ảnh sản phẩm © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA. Rev2024.3.28.7077

Your skill will accomplishwhat the force of many cannot Perl

Passing URL parameters to a CGI script from the shell

by Bilbo (Pilgrim)
on Apr 01, 2003 at 19:05UTC( [id://247314]=perlquestion: print w/replies, xml ) Need Help??

tên miền Nodelet? Node Status?

Bilbo has asked for the wisdom of the Perl Monks concerning the following question:

I feel that I must be missing something obvious here. I am trying to chạy thử a CGI script (using the CGI module) by running it from the shell. I can pass parameters to lớn be recovered using the param method by specifying them on the command line, as shown in the CGI documentation. How bởi I pass parameters to be retrieved using the url-param method? In other words, how vì chưng I make my script think that it has been invoked by CGI with a URL like http://myhost.org.uk/forum.cgi?mode=1?

Replies are listed "Best First".

Xem thêm: Nghĩa của từ content đi với gì, tra từ content

Re: Passing URL parameters to a CGI script from the shellby cbro (Pilgrim) on Apr 01, 2003 at 19:27UTC
Try setting the QUERY_STRING environment variable. Just load it up with all of the values, & run your CGI script via command line.For example:

...where iid, rid, and ptype are all normally passed via URL as you outlined in your question.

Re: Re: Passing URL parameters lớn a CGI script from the shellby Bilbo (Pilgrim) on Apr 02, 2003 at 08:34UTC
Thanks. That did the trick.

Re: Passing URL parameters to lớn a CGI script from the shellby jasonk (Parson) on Apr 01, 2003 at 19:36UTC

url_param is only useful when POSTing to a CGI, to lớn differentiate between the posted values and the url values. When you use the command line debugging functionality, CGI.pm simply turns the options you give it into a query string, và simulates a GET (technically it isn"t a GET, because from the command line you get no $REQUEST_METHOD, but it works similarly), the code doesn"t provide this functionality from the command line.

We"re not surrounded, we"re in a target-rich environment!
Re: Passing URL parameters khổng lồ a CGI script from the shellby The Mad Hatter (Priest) on Apr 01, 2003 at 19:59UTC
What jasonk said was good. If you don"t really need to lớn use url_param (I don"t know if you do), you can use the param method (which will fetch data from POST or GET) & easily emulate the script being passed data by specifying name=value pairs as arguments. For example: ./myscript.cgi mode=1 foo=bar.

Update Just wanted to lưu ý that cbro was right about using QUERY_STRING.

Re: Passing URL parameters khổng lồ a CGI script from the shellby Anonymous Monk on Jan 16, năm ngoái at 07:24UTC
Log In? Username:
remember me
What"s my password?
Create A New User

www.com | www.net | www.org

node history
Monks graciously bestowed by Tim Vroom. Perl
Monks somehow became entangled with The Perl Foundation. Wonderful website Servers and Bandwidth Generously Provided by pair Networks Built with the Perl programming language.