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

Opening files on IIS

by ucanflyit (Initiate)
on Mar 08, 2004 at 22:23 UTC ( [id://334957]=perlquestion: print w/replies, xml ) Need Help??

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

I'm having trouble opening a text file in the script below. It works fine on AIX Unix but I can't seem to get the syntax right to open a file on IIS. It just says "can't open file". The script and txt files are both in the cgi-bin directory relative to the root web. Do I have to put the entire path in back to C:\ or can it be relative to the root web?
#!d:\perl use CGI qw(:standard); $ip= param("IPNum"); print "Content-type:text/html\n\n"; print <<WEB_PAGE; <html> <title>DLS Peers</title> <body> <h1>DLS Peer Information</h1> <table border=1 width=40%> <tr><th>Peers</th></tr> </table> WEB_PAGE # IP number is now passed to this script via the dslentry.htm form #print ("DLS Peer Table"); #print ("Enter Circuitless IP #\t"); #$ip=<STDIN>; #chop ($ip); print "<h3>IP number is $ip</h3>"; # Split the IP # and get the third octet @octet=split(/\./,$ip); # print ("The third octet = $octet[2]"); $trd = $octet[2]; print "<h3>The 3rd Octet is $trd</h3>"; # Build csv Array # Open the dls txt file and search for the 3rd octet $dir = "/cgi-bin/dls.txt"; open(PEERS, $dir) or print "Can't open File"; @peers = <PEERS>; print "<h3>Peers Below</h3>"; print @peers; @csv = (grep /^$trd/, @peers) or die "No such IP"; @ncsv = split(/,/, $csv[0]);

jdporter - added code tags

Replies are listed 'Best First'.
Re: Opening files on IIS
by NetWallah (Canon) on Mar 08, 2004 at 23:56 UTC
    The Leading slash in
    $dir = "/cgi-bin/dls.txt";
    causes it to go to the Root of the disk.

    Try it without the leading slash, to allow relative paths:

    $dir = "cgi-bin/dls.txt";
      Thanks for the help!
Re: Opening files on IIS
by AcidHawk (Vicar) on Mar 09, 2004 at 05:54 UTC

    Surely if the text file and the script are in the same dir you don't need the path at all.

    Try changing $dir = "/cgi-bin/dls.txt"; to $dir = "./dls.txt";

    -----
    Of all the things I've lost in my life, its my mind I miss the most.
      thanks for your help!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://334957]
Approved by jdporter
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (3)
As of 2024-04-26 00:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found