Re: Paths help



hope@xxxxxxxx wrote:

I trying to sort out how to put in pathes

I have apache setup like
C:\apache\Apache2\
cgi-bin
Htdocs

Now in my cgi-bin folder I have a folder called test
In this folder I have a script called test.cgi

It has in it
## GET USERS

$folder="users\\uxxx\\perdata\\users";
@userfiles=`dir $folder`;
$folder="users/uxxx/perdata/users";

Now my users are in

C:\apache\Apache2\htdocs\web1\test\users

I have put in

$folder="..\\..\\htdocs\\web1\\test\\users";
@userfiles=`dir $folder`;
$folder="../../htdocs/web1/test/users";

That does not work

I have put in

$folder="htdocs\\web1\\test\\users";
@userfiles=`dir $folder`;
$folder="htdocs/web1/test/users";

That does not work

I have put in
$folder="\web1\\test\\users";
@userfiles=`dir $folder`;
$folder="/htdocs/web1/test/users";


That does not work

It appears that you have just randomly changed things in the hope that, at
one point, the script would behave as you expect it to behave.
It reminds one of the idea that, given enough monkeys with typewriters, one
day Shakespear's Hamlet will be typed by one of them.
The drawbacks of this approach are
1. You have no idea why it suddenly works
2. You have no idea what the side effects of your action are.
You may have built in a large security hole or a bug that will bite you in
the furture.

PLEASE can some one help on this paths thing for me

1) why the two \\ in the first one

The backslash (\) is a special character in Perl's double-quoted strings: it
sometimes gives special meaning to the letter which follows it: it will
turn an n into a newline, an r into a carriage return, a closing " into a
quote within a string etc. Here it will turn the special character \ into a
simple character \.

2) Then why the/ on the second one.

The / is not a special character in Perl's strings (Note that some OSes do
not mind if you wrote a//path//to//a//file).

The difference between these two strings will become obvious, if you use
them with external programs:

The first strings will turn into 'a\path\to\a\file' (note the single quote!)
while the second ones will turn into 'a/path/to/a/file'. If you pass either
of these strings to a

@userfiles=`dir $folder`;

the "dir" command will, in one case, find a backslashed path and in the
other case a forward-slashed path. The first one is OK, the second one
isn't.
Beware that if you passed a pathname to a Perl-builtin, then perl will
automagically convert forward slashes to a backslashes.

Can you please explain in simple terms how you go from one folder up from
where you are or down from where you are.

See Brian's post.

--
josef punkt moellers bei gmx punkt de
.



Relevant Pages

  • Where are the strings in gc.get_objects?
    ... script to show the numbers of each different type of object. ... for key in keys: ... I get similar results on both Python 2.4 and Python 2.5. ... Can anyone explain were the strings are? ...
    (comp.lang.python)
  • Re: PHP realpath in localhost problem
    ... writing an application about file manager, first is to create folder. ... echo 'ERROR'; ... -- Mi web de humor satinado:http://www.demogracia.com ... strposonly compares strings, it doesn't know about files or directories. ...
    (comp.lang.php)
  • Re: PHP realpath in localhost problem
    ... The following is part of the code to create a folder: ... -- Mi sitio sobre programación web:http://borrame.com ... -- Mi web de humor satinado:http://www.demogracia.com ... Although all these strings might refer to the same directory: ...
    (comp.lang.php)
  • Python, MS SQL, and batch inserts
    ... com object, does a little formatting, and then inserts that data into ... ADODB.command objects for working with SQL. ... machine running the script. ... The overhead for recreating the strings was monster. ...
    (comp.lang.python)
  • Session losing variables?
    ... I have a script start.php and a second script proceed.php ... <?PHP ... // Strings match, so open logfile, exit if this fails. ...
    (comp.lang.php)