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

I have a script that keeps timing out the browser
how can I pass a form variable to the script from the command line? Suse linux
thanks,
paul
  • Comment on perl/linux passing form variables from command line

Replies are listed 'Best First'.
Re: perl/linux passing form variables from command line
by davido (Cardinal) on Oct 24, 2003 at 04:16 UTC
    If you're using "use CGI;" (you are, right?) it's as easy as invoking your CGI script from the command line with the parameters enumerated as 'key="value"' on the command line. I don't think it's quite that simple if you're rolling your own CGI input parser (you aren't, right?) ;)

    Check out the POD for CGI.pm; it describes pretty clearly how to input key/val parameters from the command line for the purpose of debugging scripts. Nice little feature.


    Dave


    "If I had my life to do over again, I'd be a plumber." -- Albert Einstein
      Hi Dave,
      actually I own my own server and want to go to the command line and type perl myscript.pl {pass form variable}
      -Paul
        actually I own my own server and want to go to the command line and type perl myscript.pl {pass form variable}

        Yes, and since your original question mentioned passing form data from the command line I naturally understand that to mean that you have a CGI script you want to run from the command line (possibly for debugging purposes to find out why it's hanging peoples' browsers). And if you are using: 'use CGI;' in myscript.pl, then you just do what my previous answer suggested: invoke the script from the command line with each form variable enumerated on the command line as key="value". Your script does use CGI.pm, right? If so, my previous advice was accurate whether you own your own server or use someone else's.


        Dave


        "If I had my life to do over again, I'd be a plumber." -- Albert Einstein
        actually I own my own server

        I am confused. Do you mean you wrote your own CGI parser?

Re: perl/linux passing form variables from command line
by Roger (Parson) on Oct 24, 2003 at 04:24 UTC
    Assume that your script uses the CGI module, you can run the script in debug mode from command-line. There are many ways to do this, the following method is what I normally use:

    perl cgi_script.pl var1=value1 var2=value2
    Where var1 and var2 are form variables.

      thanks guys,
      that answered my question... What I meant was I do my own hosting/administration for my site and have access to the command line; unlike 95% of people with websites....
      thanks,
      -p