Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

cgi script is not running from browser but runs from command line

by supi (Initiate)
on Dec 05, 2010 at 18:32 UTC ( #875505=perlquestion: print w/replies, xml ) Need Help??
supi has asked for the wisdom of the Perl Monks concerning the following question:

Hi all, I am developing an application and I have written a perl cgi script for it. I have to do following steps - 1. Accept 2 build numbers from user. 2. Get contents from a webpage related to those 2 numbers. 3. Compare those contents 4. Give difference to users. For 1st step i use post method. For 2nd step, i make use of getstore procedure form LWP::Simple module. I store difference in arrays. And then display it. I am facing following problem - 1. When I run the program from command line, it runs properly. 2. From browser, it displays same output as that of command line. i.e. if i have given a and b as numbers on command line, and c & b number on browser, it still displays output of a and b comparison. I am not getting the problem. But when I display post method output on browser, it is accepting numbers properly. I am not getting what is the problem. I checked permissions on files, they are proper.
  • Comment on cgi script is not running from browser but runs from command line

Replies are listed 'Best First'.
Re: cgi script is not running from browser but runs from command line
by Anonymous Monk on Dec 05, 2010 at 19:16 UTC
    I am not getting what is the problem.

    Logic error :) it seems you've hardcoded some defaults, and from the commandline you're using @ARGV, and that works, but @ARGV doesn't work from CGI, so your program falls back to the defaults

    How (Not) To Ask A Question

Re: cgi script is not running from browser but runs from command line
by ChuckularOne (Parson) on Dec 07, 2010 at 17:48 UTC

    This may not be related to your issues, but always run scripts from the command line as your cgi user. The default on Apache is "nobody". The reason for this is that the environment is completely different (and very restricted) for the nobody user.

    Once you are sure that all else is equal between the command line and the browser, you'll be in a better position to understand your problem.

      I tried changing user of apache. But no use. My program is not getting executed from browser. But runs from command line.
        Are you able to su to the user that actually runs the script? (Usually "nobody") If so. Try running the script as that user and see what errors you get. Doing this has always been helpful to me.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://875505]
Approved by Corion
Front-paged by Corion
and cookies bake in the oven...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (5)
As of 2018-06-21 04:35 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (117 votes). Check out past polls.