LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-01-2003, 10:48 PM   #1
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Rep: Reputation: 30
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?

Last edited by sk8guitar; 11-02-2003 at 12:52 AM.
 
Old 11-02-2003, 12:22 AM   #2
Kurt M. Weber
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 335

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

The topic says "home", the message says "current".
 
Old 11-02-2003, 12:49 AM   #3
Fascistchicken
Member
 
Registered: Jul 2003
Location: hellifniknow
Distribution: slackware for chickens
Posts: 182

Rep: Reputation: 30
.
 
Old 11-02-2003, 12:52 AM   #4
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Original Poster
Rep: Reputation: 30
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.
 
Old 11-02-2003, 12:53 AM   #5
Kurt M. Weber
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 335

Rep: Reputation: 36
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.
 
Old 11-02-2003, 02:28 PM   #6
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Original Poster
Rep: Reputation: 30
uhm, it may just be me but fascistchickens post is empty?
 
Old 11-02-2003, 02:33 PM   #7
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
Just look at the value of "$ENV{'PWD'}"
 
Old 11-02-2003, 03:50 PM   #8
Kurt M. Weber
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 335

Rep: Reputation: 36
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.
 
Old 11-02-2003, 05:01 PM   #9
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Original Poster
Rep: Reputation: 30
very weird, here is what i see on my screen

picture

i will try that $ENV dealy
 
Old 11-03-2003, 12:02 PM   #10
DarknessX
Member
 
Registered: Jun 2003
Location: New Jersey, USA
Distribution: Slackware & Debian
Posts: 37

Rep: Reputation: 15
even though this is of little importance, I see what sk8guitar sees ;-)
 
Old 11-03-2003, 08:32 PM   #11
LogicG8
Member
 
Registered: Jun 2003
Location: Long Island, NY
Distribution: Gentoo Unstable (what a misnomer)
Posts: 380

Rep: Reputation: 30
I see it too.
Look closely and you will see it as well.
...

.

very subtle fascistchicken.
 
Old 11-04-2003, 01:33 PM   #12
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Original Poster
Rep: Reputation: 30
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?
 
Old 11-04-2003, 01:49 PM   #13
david_ross
Moderator
 
Registered: Mar 2003
Location: Scotland
Distribution: Slackware, RedHat, Debian
Posts: 12,047

Rep: Reputation: 79
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.
 
Old 11-04-2003, 01:57 PM   #14
Kurt M. Weber
Member
 
Registered: Oct 2003
Distribution: Slackware
Posts: 335

Rep: Reputation: 36
Quote:
Originally posted by sk8guitar
very weird, here is what i see on my screen

picture
Yes, that is correct
 
Old 11-05-2003, 07:02 PM   #15
sk8guitar
Member
 
Registered: Jul 2003
Location: DC
Distribution: mandrake 9.1
Posts: 415

Original Poster
Rep: Reputation: 30
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
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache Root/Home Directory and setting up FTP for home directories? Mankind75 Linux - Newbie 6 07-23-2006 02:37 PM
c++ home directory bendeco13 Programming 2 11-04-2005 05:27 PM
QT and the home directory Pougan Linux - Newbie 3 11-02-2003 09:55 AM
cgi-perl directory init-5 General 4 09-16-2003 05:48 PM
can i set ~/public_html/perl as a perl directory for apache? doublefailure Linux - Networking 1 07-09-2002 04:31 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration