Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Can't find relative path

by NetWallah (Abbot)
on Mar 24, 2012 at 20:43 UTC ( #961437=note: print w/ replies, xml ) Need Help??


in reply to Can't find relative path

Try adding this to your code:

print "<b>$_</b>: $ENV{$_}<br>\n" for sort keys %ENV;
You should see the variables SCRIPT_TRANSLATED and SCRIPT_NAME, which contain the information you need.
SCRIPT_NAME is essentially the host absolute URL (minus the scheme, host, and port) for script, and SCRIPT_TRANSLATED is the corresponding physical file.
You can extract the path from these, and use that to prefix your "data/file.txt" before opening it.

             All great truths begin as blasphemies.
                   ― George Bernard Shaw, writer, Nobel laureate (1856-1950)


Comment on Re: Can't find relative path
Download Code
Re^2: Can't find relative path
by Anonymous Monk on Mar 24, 2012 at 23:03 UTC
    Thanks, but the question isn't how to fix it in the code; I have several solutions for that. The question is why it's happening on this server and not on my previous (shared hosting) servers. Problem is I have a couple hundred previously-built Perl modules that expect to see a relative path, and I don't want to have to go through & rewrite them all if there's a way to fix Perl or the server to actually use the relative path.
      How about adding a symbolic link on the server, from the directory it is trying to access, to the directory where the data is ?

                   All great truths begin as blasphemies.
                         ― George Bernard Shaw, writer, Nobel laureate (1856-1950)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://961437]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-10-25 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls