LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   program knowing home directory (perl)? (https://www.linuxquestions.org/questions/programming-9/program-knowing-home-directory-perl-111324/)

sk8guitar 11-01-2003 10:48 PM

program knowing current directory (perl)?
 
hey, i am writing this crappy little script that will just create an html file from the contents of the directory i am in. right now the script just uses CWD but i have to copy and paste it into each directoyr i want to do this on, which is a pain in the butt. so i would like to be able to make this program "global" (put it in the usr bin) and somehow have it know what direcotory i am in. is there any way for this to happen?

Kurt M. Weber 11-02-2003 12:22 AM

Wait a minute--do you want it to know the home directory or the current directory?

The topic says "home", the message says "current".

Fascistchicken 11-02-2003 12:49 AM

.

sk8guitar 11-02-2003 12:52 AM

my bad. i want the program to be global. but i want it to konw what folder i am in. so say i am in /home/user/public_html/bla. i want to call the program, and it will create an index.html file in public_html/bla with the files in that folder. so, the topic should say current, and i will change that. thanks.

Kurt M. Weber 11-02-2003 12:53 AM

In that case, Fascistchicken explained it very clearly and simply.

Although that may simply be a shell construct (I don't know) in which case it wouldn't work anywhere else.

sk8guitar 11-02-2003 02:28 PM

uhm, it may just be me but fascistchickens post is empty?

david_ross 11-02-2003 02:33 PM

Just look at the value of "$ENV{'PWD'}"

Kurt M. Weber 11-02-2003 03:50 PM

Quote:

Originally posted by sk8guitar
uhm, it may just be me but fascistchickens post is empty?
No, it's not empty. The answer is right there in the body of his post.

sk8guitar 11-02-2003 05:01 PM

very weird, here is what i see on my screen

picture

i will try that $ENV dealy

DarknessX 11-03-2003 12:02 PM

even though this is of little importance, I see what sk8guitar sees ;-)

LogicG8 11-03-2003 08:32 PM

I see it too.
Look closely and you will see it as well.
...

;) .

very subtle fascistchicken.

sk8guitar 11-04-2003 01:33 PM

hahaha if he means the ./ to say that its in the current directory, i don't know if that will work becuase the script is in one directory and i am in another. and i tried in the shell to do $ENV{'PWD'} and it didn't know what i was talking about? am i typing this in wrong?

david_ross 11-04-2003 01:49 PM

Quote:

Originally posted by sk8guitar
hahaha if he means the ./ to say that its in the current directory, i don't know if that will work becuase the script is in one directory and i am in another. and i tried in the shell to do $ENV{'PWD'} and it didn't know what i was talking about? am i typing this in wrong?
By shell I asusme you mean bash?
In the title you said perl


./ will work since it is teh directory YOU are in but it will not give you the full path - hence why I suggested the environment variable.

Kurt M. Weber 11-04-2003 01:57 PM

Quote:

Originally posted by sk8guitar
very weird, here is what i see on my screen

picture

Yes, that is correct :)

sk8guitar 11-05-2003 07:02 PM

yeah, but i tired the einvroment variable like you said it doesn't seem to be working.

Code:

[akropp@akropp akropp]$ $ENV{'PWD'}
bash: {PWD}: command not found



All times are GMT -5. The time now is 11:38 PM.