homepage Welcome to WebmasterWorld Guest from 54.196.77.82
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
How to define USR path?
toplisek




msg:4009902
 7:40 am on Oct 20, 2009 (gmt 0)

I have issue how to define real path on server.

Path is on FTP like sample: /secure/domains/myfiles

How to define correct real path not FTP if folders are at FTP /secure/domains/myfiles?
With usr which is REAL path is maybe:
/usr/secure/domains/myfiles/

Need help...

 

phranque




msg:4010043
 1:18 pm on Oct 20, 2009 (gmt 0)

not sure exactly what your question is...

that is the correct way to specify that path if /secure directory is in /usr, but there is not a "standard" directory such as "/usr" to place "ftp directories".

for example the root directory for one ftp login could be "/home/username/" and for another could be "/var/log/httpd/sitename/"

rocknbil




msg:4010273
 7:12 pm on Oct 20, 2009 (gmt 0)

Upload this script, run it on your server then DELETE it (do not leave it on your server:)

#!/usr/bin/perl
print "content-type: text/html\n\n";
foreach $v (sort keys %ENV) { print "$v $ENV{$v}<br>\n"; }

What you are looking for is the DOCUMENT_ROOT environment variable, this will reveal it, and should be the first one using sort.

Note that you may have a different path to perl,
#!/usr/bin/perl
#!/usr/local/bin/perl

Check with your host's documentation, they usually post this publicly.

janharders




msg:4010633
 8:28 am on Oct 21, 2009 (gmt 0)

Note that you may have a different path to perl,
#!/usr/bin/perl
#!/usr/local/bin/perl

I think that's what he's after. It sounds to me like he is chrooted on ftp connections.

toplisek: when you're using ftp to connect to the server (I think that's what's happening to you), you're thrown into your home directory without a possibility to get out of there and access other system directories with ftp. when you run scripts, however, they are usually run without chroot (chroot = change root, root as in root directory, not root user), so /usr will be available and so will /usr/bin/perl or /usr/local/bin/perl or wherever perl may reside on your server.

rocknbil




msg:4010937
 5:08 pm on Oct 21, 2009 (gmt 0)

By the title it seems so, but

Path is on FTP like sample: /secure/domains/myfiles
How to define correct real path not FTP if folders are at FTP /secure/domains/myfiles?

Leads me to believe he/she is looking for the full server path. Meh, sorry for the guesswork.

toplisek




msg:4010996
 6:45 pm on Oct 21, 2009 (gmt 0)

Exactly, I'm looking for FULL, ABSOLUTE path, not relative
Linux server,Apache

phranque




msg:4011324
 5:48 am on Oct 22, 2009 (gmt 0)

i would go with rocknbil's solution.
you won't always be able to see the full path in the ftp client.
using rocknbil's script if you are on virtual hosting you might have to look at another environment variable like SCRIPT_FILENAME to get the full path to your document root directory.

rocknbil




msg:4011721
 6:56 pm on Oct 22, 2009 (gmt 0)

But . . . that's what I'm saying, $ENV{'DOCUMENT_ROOT'} **is** the path to the domain's root, first in the list with that three-liner script. :-)

phranque




msg:4011796
 8:31 pm on Oct 22, 2009 (gmt 0)

not always - one of my tests was on a virtual host where i got the following results:
DOCUMENT_ROOT /var/www/htdocs
SCRIPT_FILENAME /var/www/htdocs/example.com/cgi-bin/env.cgi
SCRIPT_NAME /cgi-bin/env.cgi
SERVER_NAME example.com

"the real document root" for this site is /var/www/htdocs/example.com

rocknbil




msg:4011946
 12:32 am on Oct 23, 2009 (gmt 0)

Aye, and ye be correct, forgot all about virtual hosts. :-P

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved