http://www.perlmonks.org?node_id=1010187

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

I am writing a CGI script.. When i run it through web browser, The values of variables present in my environment doesn't appear.. How to get the value of my local (not cgi variables) variables displayed through browser.

Replies are listed 'Best First'.
Re: Urgent Help required with PERL CGI
by Corion (Patriarch) on Dec 24, 2012 at 13:27 UTC

    Your web server is running your CGI script as a different user than "your user", and/or it does not set up your login environment.

    Also see Get default login environment and the discussion that follows it.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Urgent Help required with PERL CGI
by blue_cowdawg (Monsignor) on Dec 24, 2012 at 15:46 UTC
        The values of variables present in my environment doesn't appear.. How to get the value of my local (not cgi variables) variables displayed through browser.

    This comes as no surprise to me and as Corion and others have pointed out CGI usually runs as its own userid. For instance on Apache based web environments the userid can be one of but not limited to:

    • apache
    • httpd
    • web
    • www
    • www-data
    • www-user
    • nobody
    • noaccess
    • nofiles
    with the last three given in descending order of likelihood in my experience. My own hosting environment that I rent out uses the same account as the person renting space. Makes my life much easier.

    My advise to you is to never count on your personal account's environment to be available to you in a CGI script. When writing CGI I either hardcode what I need (not the ideal) or I set up a configuration file (better) with what I need. If you use FindBin to find where the script is running from and if your configuration file is in a directory related to where the script is being run you can easily open that configuration file and populate what you need to run the CGI.

    Hope this helps...


    Peter L. Berghold -- Unix Professional
    Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg
Re: Urgent Help required with PERL CGI
by Anonymous Monk on Dec 24, 2012 at 21:07 UTC
    The monastery needs a troll filter with any node containing the words "urgent help" sent to /dev/null.
      It does have a troll filter - the original person who approved it, and Consider requests.
      A Monk aims to give answers to those who have none, and to learn from those who know more.