Operating System - HP-UX
1829750 Members
1429 Online
109992 Solutions
New Discussion

Where have my command line parameters gone?

 
SOLVED
Go to solution
Gordon Brown_5
Frequent Advisor

Where have my command line parameters gone?

I have a PERL script that runs fine from the UNIX command line , however when the script is run under mod_perl in APACHE the $ARGV's are empty - probably because something has 'shifted' them.

Question is where have the parameters gone to and how do I access them ?

Thanks in advance

Gordon
Older than the 840
6 REPLIES 6
Fred Ruffet
Honored Contributor

Re: Where have my command line parameters gone?

To use perl as a CGI script you should use the CGI module. You can then find parameters sent to your script by browser with param method :

use CGI;
$page=new CGI;
$name=$page->param('name');

for more information :
http://www.perldoc.com/perl5.8.0/lib/CGI.html
--

"Reality is just a point of view." (P. K. D.)
Gordon Brown_5
Frequent Advisor

Re: Where have my command line parameters gone?

I have no control over the passing of parameters - they are sent in by a 3rd party application - this works with IIS.

Example :

http://121.0.1.1/docsearch.pl?"op:op"+""+"op_order_entry:order_entry"+"main"+"sub1"


Obviously this gets parsed by something - what ? And where is thge parsed result; I don't have the time or inclination to learn mod_perl.

The alternative of course is parse it myself so how do I get Apache to run perl without CGI or mod_perl ?

Older than the 840
Mark Grant
Honored Contributor
Solution

Re: Where have my command line parameters gone?

Gordon,

In a perl script started from apache, without any fancy modules, arguments are not passed to the script but are available the environment. For example, if your script where to parse form data from an html form, you would do something like the following.

The arguments will be, in fact, passed as one string separated by "&" into the environment variable "QUERY_STRING". You can get at them with something like.

@ARGARRAY=split "&", $ENV{QUERY_STRING};

Then you can, for example, get the first set like this

($variable,$value)=split "=", $ARGV[1];

Perl modules may handle it differently but I have never used any of the CGI modules.




Never preceed any demonstration with anything more predictive than "watch this"
Gordon Brown_5
Frequent Advisor

Re: Where have my command line parameters gone?

Thanks Mark,

That was the clear concise answer I have spent two days searching the Web for.

Enjoy the 10 points
Gordon
Older than the 840
Elmar P. Kolkman
Honored Contributor

Re: Where have my command line parameters gone?

Could be me, but I think you forgot to assign the points ;-)
Every problem has at least one solution. Only some solutions are harder to find.
Gordon Brown_5
Frequent Advisor

Re: Where have my command line parameters gone?

Sorry Mark,

I set up the points and sent the reply - but it seems that the system only carried out the last task.

Points now assigned and thanks again.

G
Older than the 840