?
Solved

ENV variables question

Posted on 1999-10-31
5
Medium Priority
?
295 Views
Last Modified: 2012-05-04
i have this perl script which checks out a couple of ENV type variables .. why is it that 'SCRIPT_FILENAME' keeps coming back as blank/undefined?

server_name and scriptname is returning fine.

Running Perl5 on NT4 IIS.
------------------------
#!/usr/local/bin/perl

print "Content-type: text/html\n\n";
print "<html><head></head><body>\n";
print "Your path is working and pointing to Perl version:<p>\n";
print "<B>$]</B><p>\n";
print "The complete path to this script is:<p>\n";
print "<font color=red><B>$ENV{'SCRIPT_FILENAME'}</B></font><p>\n";
print "The relative URL of this script (used in forms) is:<p>\n";
print "<B>$ENV{'SCRIPT_NAME'}</B>\n";
print "Your server returns the following domain name for your site:<p>\n";
print "<B>$ENV{'SERVER_NAME'}</b><p>\n";
print "</body></html>\n";

exit;
0
Comment
Question by:eriklee
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 2173110
Try $ENV{'SCRIPT_NAME'}
0
 

Author Comment

by:eriklee
ID: 2173236
erh..actually that one  is already in the script. what won't work is SCRIPT_FILENAME.
0
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 2173277
SCRIPT_FILENAME is not one of the CGI session variables. What data are you hoping to see in SCRIPT_FILENAME? See
http://stein.cshl.org/WWW/software/CGI/#environment
0
 
LVL 8

Accepted Solution

by:
jhurst earned 150 total points
ID: 2181282
As has been said, not all servers provide them all.  I would suggest that you imnplement env.cgi so you can see what your server has.  Here is a copy of it:

#!/usr/bin/perl

###########################################################################
#                     environment_variables.cgi                           #
#                                                                         #
# This script was written by Selena Sol (selena@eff.org                   #
# http://www.eff.org/~erict) having been inspired by countless other      #
# perl authors.  Feel free to copy, cite, reference, sample, borrow or    #
# plagiarize the contents.  However, please let me know where it goes so  #
# that I can at least watch and take part in the development of the       #
# memes. Information wants to be free, support public domain freware.     #
#                                                                         #
# Version: 2.0                                                            #
# Last Modified: 5-12-96                                                  #
# Description: This script will output all of the environment variables   #
#      available for use                                                  #  
# Usage: This script must be placed in a directory which allows cgi       #
#      executables and must have its permissions set such that the web    #
#      server has permission to execute it.                               #
#                                                                         #
###########################################################################

# First, print out the HTTP header.

  print "Content-type: text/html\n\n";

# Create a list of environment variables by gathering all the "keys" in the
# %ENV associative array.

  @environment_variables = keys (%ENV);

# For ever environment variable in the @environment_variables list, print
# the variable and then print its associated value.  Then quit.

  foreach $environment_variable (@environment_variables)
    {
    print "$environment_variable = $ENV{$environment_variable}<BR>\n";
    }
  exit;

0
 

Author Comment

by:eriklee
ID: 2267492
thanks
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
In the distant past (last year) I hacked together a little toy that would allow a couple of Manager types to query, preview, and extract data from a number of MongoDB instances, to their tool of choice: Excel (http://dilbert.com/strips/comic/2007-08…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

588 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question