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 John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

server root - newbie

Status
Not open for further replies.

tester321

Programmer
Mar 13, 2007
150
CA
hi i'm trying to determine the server root:

$basedir="/the_server_root/the_directory";

I was wondering (since i'm not "perly" by no means), if some can quickly script me something to determine this.

Much appreciated! Thanks.
 
What context are you running this in? And what exactly do you mean by the "server root"?
 
That appears to be the path to where you serve your web files from (the DocumentRoot of your web site).

On Linux systems, this tends to be along the lines of:

Code:
/home/kirsle/public_html

On Windows systems, you'd probably use a file path:

Code:
C:/www/public_html

Assuming you have your files there.

The DocumentRoot is where the web files are served from (the root of your web server). So, when somebody access yourdomain.com/index.html, where does this index.html exist at on your server?

i.e.
/home/kirsle/public_html/index.html

Ask your sysadmin if you're not sure about this.

-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
 
With IIS the DocRoot is C:\Inetpub\

"We must fall back upon the old axiom that when all other contingencies fail, whatever remains, however improbable, must be the truth." - Sherlock Holmes
 
Thanks Kirsle, sysAdmin in Disney World </jeleaous>, probably riding that 'Twilite Zone Tower of Terror'

I understand, in Window iis we call this the 'server mappath' like whats used in a connection string to db, in this case what i understand is that i should use the server physical mappath to the folder of the files that call the cgi and dat files, correct? I'll give a go, and return.

Thanks!
 
no luck, i wrote a vb script to get me the physical path, used it, and nothing. I know that the cgi-bin folder was set correctly cause when i reference it like so:


I get message: no parameters!

hmmm... i would like to know how i can get the pl file to instantiate a request, how to pass a var to it via the url, can i just use url parameters via a queryString?

Thanks
 
This Perl script should do:

Code:
#!/usr/bin/perl -w

print "Content-Type: text/html\n\n";
foreach (keys %ENV) {
	print "$_ = $ENV{$_}<p>\n";
}

On my server, it prints this page:

Code:
SCRIPT_NAME = /wizards/env.cgi

SERVER_NAME = [URL unfurl="true"]www.cuvou.com[/URL]

SERVER_ADMIN = root@upsilon.cuvou.com

HTTP_ACCEPT_ENCODING = gzip,deflate

HTTP_CONNECTION = keep-alive

REQUEST_METHOD = GET

HTTP_ACCEPT = text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5

[COLOR=blue]SCRIPT_FILENAME = /home/kirsle/public_html/cuvou.com/wizards/env.cgi[/color]

SERVER_SOFTWARE = Apache/2.2.4 (Fedora)

HTTP_ACCEPT_CHARSET = ISO-8859-1,utf-8;q=0.7,*;q=0.7

QUERY_STRING =

REMOTE_PORT = 33964

HTTP_USER_AGENT = Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.5) Gecko/20070718 Fedora/2.0.0.5-1.fc7 Firefox/2.0.0.5

SERVER_PORT = 80

SERVER_SIGNATURE =
Apache/2.2.4 (Fedora) Server at [URL unfurl="true"]www.cuvou.com[/URL] Port 80

HTTP_ACCEPT_LANGUAGE = en-us,en;q=0.5

REMOTE_ADDR = 68.61.139.194

HTTP_KEEP_ALIVE = 300

SERVER_PROTOCOL = HTTP/1.1

PATH = /sbin:/usr/sbin:/bin:/usr/bin

REQUEST_URI = /wizards/env.cgi

GATEWAY_INTERFACE = CGI/1.1

SERVER_ADDR = 68.61.139.194

[COLOR=blue]DOCUMENT_ROOT = /home/kirsle/public_html/cuvou.com[/color]

HTTP_HOST = www.cuvou.com

In my case, I was provided a DOCUMENT_ROOT variable by Apache that gave me exactly what my document root was. Or, I could've looked at SCRIPT_FILENAME and figured out where my document root was relative to env.cgi. Printing out your environment and taking a look tends to provide all kinds of handy information.

-------------
Cuvou.com | My personal homepage
Project Fearless | My web blog
 
if the application calls it from a URI that would be correct. If the application calls the perl script from a machine path it would not be correct.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
also since i'm using iis the path is like:
C:\Inetpub\versus:
/home/kirsle/public_html

so with the slash in different direction would i have to alter the file for this:
wher there is:
open (USERLIST,"<$basedir\$userfile") || die $!;

should it be:

open (USERLIST,"<$basedir/$userfile") || die $!;

thanks
 
in perl you can use unix style slashes.. / instead of \ . \'s are used to escape.

So if you had
$basedir\$userfile
Then the second $ would have not been interpreted as a variable but as a literal $


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
ok i was tinking with the path setting in the flash file and the pl file and i got this error message:

The specified CGI application misbehaved by not returning a complete set of HTTP headers.

the helloWorld.pl script still works. I comb thru the first 5 page on google about this error and since its not iis i'm not sure, any suggestions?
 
Did you print this in your perl script before you printed ANYTHING else?
print "Content-Type: text/html\n\n";

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
nope.

first print statement:

print "Content-type: text/plain\n\n";
 
is Content-Type case sensitive???

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
as far as I know the content-type tags are not case sensitive, but it may depend on the DTD used, if any.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Are you calling the perl script directly or are you calling it from the php?

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[noevil]
Travis - Those Who Say It Cannot Be Done Are Usually Interrupted by Someone Else Doing It; Give the wrong symptoms, get the wrong solutions;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top