Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for
Perl Environment Variables missing
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Perl Environment Variables missing
Perl Environment Variables missing
16-03-2010 6:47 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
In my perl scripts, I use the following environment variable:
$ENV{C_DOCUMENT_ROOT}
to get the path to to root of the webspace (e.g. /files/home1/username etc)
That env variable no longer exists, as such some of my perl scripts that read/write files are failing.
I have a perl script that prints them all out here:
http://ccgi.unclezen.plus.com/cgi-bin/dev/test/printenv.pl
As you can see this particular env variable is missing and there doesnt seem to be an equivalent.
Help!
$ENV{C_DOCUMENT_ROOT}
to get the path to to root of the webspace (e.g. /files/home1/username etc)
That env variable no longer exists, as such some of my perl scripts that read/write files are failing.
I have a perl script that prints them all out here:
http://ccgi.unclezen.plus.com/cgi-bin/dev/test/printenv.pl
As you can see this particular env variable is missing and there doesnt seem to be an equivalent.
Help!
Message 1 of 3
(999 Views)
2 REPLIES 2
Re: Perl Environment Variables missing
16-03-2010 8:32 PM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
$ENV{C_DOCUMENT_ROOT} was a non-standard variable and, as you say, is no longer present. The "official" one is DOCUMENT_ROOT but that was not suitably set before, and isn't now.
I suggest you build your own value by accessing SCRIPT_FILENAME and strip SCRIPT_URL from it. That's the approach I use which works fine.
In PHP I use
preg_match("£(.*){$_SERVER['SCRIPT_URL']}\$£", $_SERVER['SCRIPT_FILENAME'], $matches);
$docroot = "{$matches[1]}/";
David
Edit: added PHP example
I suggest you build your own value by accessing SCRIPT_FILENAME and strip SCRIPT_URL from it. That's the approach I use which works fine.
In PHP I use
preg_match("£(.*){$_SERVER['SCRIPT_URL']}\$£", $_SERVER['SCRIPT_FILENAME'], $matches);
$docroot = "{$matches[1]}/";
David
Edit: added PHP example
David
Message 2 of 3
(371 Views)
Re: Perl Environment Variables missing
17-03-2010 8:11 AM
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Report to Moderator
Thanks, I was rather hoping not to have to write a piece of code. I was hoping things would work as before, like nothing had gone wrong. But if I have to its no sweat. Maybe plus net will add this or an equivalent env variable
Message 3 of 3
(371 Views)
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Plusnet Community
- :
- Forum
- :
- Help with my Plusnet services
- :
- Everything else
- :
- Perl Environment Variables missing