Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

why a simple script ckecking the existance of a file doesn't work

why a simple script ckecking the existance of a file doesn't work

why a simple script ckecking the existance of a file doesn't work

I put this script in an IIs4 server (configure to run perl script)  and use an internet explorer 4 to execute this script, I put the test.txt file in the script directory but it return always "file does not exist". When i put the test.txt file in the home directoty of the web site (d:\data\wwwroot) it return "file test.txt exist". I don't want to use a relative path in the syntax, how can i do that, is it something to configure on my web site or something to add in my code ?

there is the script:

use CGI_Lite;

# Param #

# Main #

print "HTTP/1.0 200 OK\r\n" if $ENV{PERLXS} eq "PerlIS";

# Create HTML Page
print "Content-Type: text/html\n\n";

if ( -e "test.txt" ) {
file test.txt exists
} else {
file test.txt DOES NOT EXISTS

RE: why a simple script ckecking the existance of a file doesn't work

It looks like your default working directory is the root document directory, so that's why you can see the "test.txt" file.

From a security point of view, it's probably a good idea to hard code references to the file in the perl script.  If you don't do this, then you could potentially leave yourself open to security problems as your CGI scripts become more advanced.  Personally, I always hard code paths to required files as a matter of personal best practice.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close