Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Unix Question about Environment Variables

by kidd (Curate)
on Jul 20, 2002 at 22:05 UTC ( #183685=perlquestion: print w/replies, xml ) Need Help??
kidd has asked for the wisdom of the Perl Monks concerning the following question:

This is really a UNIX question, but didnt know where else to post it...

I have a hosting service that gives me access to the shell of UNIx, and I can do whatever I want...

I have a perl on Linux but I dont know how to do this:

  • I want to setup the ENV_VARIABLEs because I dont have all of them. Im particulary(spelling?) interested in been able to see the "REMOTE_USER". I read somewhere that when you have access to the shell you are able to do this.

    It would be great if someone can help me out. Just in case im in bash.


    Edited: ~Tue Jul 23 15:28:54 2002 (GMT), by footpad: Changed title (for full thread), per Consideration

  • Replies are listed 'Best First'.
    Re: Unix Question about Environment Variables
    by dws (Chancellor) on Jul 20, 2002 at 23:05 UTC
      You don't say why you want to access REMOTE_USER, and I'm guessing from context that you might misunderstand what REMOTE_USER is, and how it ordinarily gets set.

      A web server will set REMOTE_USER on behalf of a CGI script if the script is password protected, or if the directory in which the script resides is password protected, and if the user has successfully logged in. You won't see REMOTE_USER in a shell's environment, nor should you expect to.

      The only reason you would want to set REMOTE_USER yourself is if you're debugging a CGI script that depends up on it.

    Re: Unix Question about Environment Variables
    by perigeeV (Hermit) on Jul 20, 2002 at 22:26 UTC

      prompt$ export REMOTE_USER="foo"

      But I doubt that's what you want to do. That just sets it for the current and any child shells invoked. If you are looking for the string as passed by a webserver to your CGI script, then you are limited to pages that are protected by an .htaccess file.
      No .htaccess, no $ENV{'REMOTE_USER'}.
 about the other variables? Do I use the same syntax?

          The %ENV hash gives you all the environment variables. But I think we should stop right now and take a look at Ovid's splendid CGI Course.

    Re: Unix Question about Environment Variables
    by hacker (Priest) on Jul 21, 2002 at 12:01 UTC
      To expose the environment that your client browser sees for each request, you could use the following (note, do not leave this lingering in production code, only use it for debugging):
      print "<!--\n"; foreach my $param ( sort keys %ENV ) { print "$param is: $ENV{$param}\n"; } print "-->\n";

    Log In?

    What's my password?
    Create A New User
    Node Status?
    node history
    Node Type: perlquestion [id://183685]
    Approved by footpad
    [jedikaiti]: Shiney!

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (5)
    As of 2018-04-24 18:35 GMT
    Find Nodes?
      Voting Booth?