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

I have a script that is checking web links and works on my local NT workstation. But I now need the NT web server's path so I can check web pages on the web server.

How can I get the web server path?
If my server is called "webserver" and I can put "webserver/mypage.html" in my browser url location entry and it brings up the page then I should be able to use:
"/webserver/mypage.html" as my path name in my script? But it says it cant find the directory and file.
Please advise a way I can find out my server's absolute path so I can use it in my script?? I really just need advice on finding the specific web server absolute path so I can use it in my script. Not looking for any script assistance. Also I do have the web server's IP address if that is something I can use? Here is how it works so far fetching local files:
my $start_dir = '/inetpub/wwwroot/expo/cony.html';
Now my attempt on checking a web page on my NT server:
my $start_dir = '/webserver/mypage.html';

Replies are listed 'Best First'.
Re: Getting web server absolute path
by reyjrar (Hermit) on Aug 27, 2002 at 14:38 UTC
    Your description is a little lacking in what about you're looking to do. From the sounds of it, you're parsing html files locally on the webserver and you want the script to find the DocumentRoot and look in there to do things. If that's what you mean, and you're looking to deploy this on several machines with DocumentRoot's in various places, I can only see two ways.

    1. Statically configuring each script or creating a config file to live with the script that contains the directories to parse.

    2. Reading the configuration file for the web server to find the DocumentRoot (or similar IIS thingy), BUT you'd need to know where that file lives.

    wait, thought of something else.. You might want to check CPAN out, I believe File::Find will grant you the ability to quest for all *.htm* files on a given system.

    But like I said, from this description its a bit difficult to get a clear idea of what you're trying. When I read the title, I thought of the CGI::url() method that I use alot in my CGI scripts:
    use CGI; my $c = new CGI; my $SCRIPT = $c->url( -absolute=>1 );

    That just gives me the absolute path from the server root to use with page navigation from a client side browser.

    anyways, if you clarify some more, perhaps I can offer more assistance.

    -brad..
Re: Getting web server absolute path
by Anonymous Monk on Aug 27, 2002 at 13:43 UTC
    sorry I made a mistake on my previous post. This is how it works so far fetching local files:
    my $start_dir = '/inetpub/wwwroot/mypage.html';

    My attempt on checking a web page on my NT server:
    my $start_dir = '/webserver/mypage.html';
Re: Getting web server absolute path
by valdez (Monsignor) on Aug 27, 2002 at 13:56 UTC

    Please, can you tell us what kind of web server are you using?
    Thanks, Valerio