Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

admfama

IS-IT--Management
May 23, 2000
1
BE
I put this script in an IIs4 server (configure to run perl script)&nbsp;&nbsp;and use an internet explorer 4 to execute this script, I put the test.txt file in the script directory but it return always &quot;file does not exist&quot;. When i put the test.txt file in the home directoty of the web site (d:\data\ it return &quot;file test.txt exist&quot;. 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 ?<br><br>there is the script:<br><br><br><br>use CGI_Lite;<br><br>#-------#<br># Param #<br>#-------#<br><br><br>#------#<br># Main #<br>#------#<br><br><br>print &quot;HTTP/1.0 200 OK\r\n&quot; if $ENV{PERLXS} eq &quot;PerlIS&quot;;<br><br>&nbsp;<br># Create HTML Page<br>print &quot;Content-Type: text/html\n\n&quot;;<br><br><br>if ( -e &quot;test.txt&quot; ) {<br>print&lt;&lt;END_OF_PAGE;<br> file test.txt exists<br>END_OF_PAGE<br>} else {<br>print&lt;&lt;END_OF_PAGE;<br> file test.txt DOES NOT EXISTS<br>END_OF_PAGE<br>}<br><br>
 
It looks like your default working directory is the root document directory, so that's why you can see the &quot;test.txt&quot; file.<br><br>From a security point of view, it's probably a good idea to hard code references to the file in the perl script.&nbsp;&nbsp;If you don't do this, then you could potentially leave yourself open to security problems as your CGI scripts become more advanced.&nbsp;&nbsp;Personally, I always hard code paths to required files as a matter of personal best practice.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top