473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How do I find my runtime directory?


This seems like a simple thing, but I can't find anything in the "Perl
Cookbook" or the online Perl docs to answer this.

When a script runs from my host's server, the working directory
doesn't appear to be the directory the script is located in. (They
have Perl running under IIS, I don't know what versions).

I tried File::Spec->curdir() , but it just returns ".", which is
accurate, but not very helpful.

Does anyone know a way to do this?

--
Joe Cosby
http://joecosby.com/
pablo picasso well, some people try to pick up girls and they get called an asshole.
this never happened to pablo picasso. he could walk down your street and girls
could not resist his stare and pablo picasso never got called an asshole. the girls
would turn the colour of an avocado when he drove down their street in his eldorado.
he could drive down your street and girls could not resist his stare. pablo picasso
never got called the asshole. oh well be not schmuck, be not obnoxious, be not
bell-bottom bummer or asshole. this is the story of pablo picasso. he could walk
down your street and girls could not resist his stare, so pablo picasso never got
called an asshole. not like you. (j.richman)
Jul 19 '05 #1
6 7631
On Sun, 04 Apr 2004 12:18:09 -0700, Joe Cosby
<jo******@SPAMBLOCKmindspring.com> wrote:

This seems like a simple thing, but I can't find anything in the "Perl
Cookbook" or the online Perl docs to answer this.

When a script runs from my host's server, the working directory
doesn't appear to be the directory the script is located in. (They
have Perl running under IIS, I don't know what versions).

I tried File::Spec->curdir() , but it just returns ".", which is
accurate, but not very helpful.

Does anyone know a way to do this?


Maybe I should clarify what I'm trying to accomplish a little.

I want to be have a relative directory structure within my code. For
instance, within a "code" directoy I have scripts, then a subdirectory
"templates" within "code" contains html templates.

I want to be able to read the templates by loading a file
"templates/templatename.htm", instead of having to hard-code
"e:\www\joecosby\code\templates\templatename.h tm" (the path on the
server) in the code I upload, ""C:\My
Documents\webpage\newstuff\code\templates\template name.htm" (the path
on my local machine) in the code before I upload it, etc.

I mean it's the same idea as using relative references versus absolute
references in HTML, it saves me from a huge amount of maintenance
work.

The perl environment seems to know what directory my script is running
from, when I get error messages they include the complete path to the
script, so if I could just chdir() to that directory at the start of
all my scripts that would at least be a workable solution.

--
Joe Cosby
http://joecosby.com/
"Now that I've inspired a character in a Godzilla movie, all I
really still desire is for several Ingmar Bergman characters to sit in a
circle and read my reviews to one another in hushed tones." - Roger Ebert

Jul 19 '05 #2
Joe Cosby wrote:
When a script runs from my host's server, the working directory
doesn't appear to be the directory the script is located in.
It would be a rare coincidence indeed if the script were located in the
current working directory.
Does anyone know a way to do this?


perldoc Cwd

jue
Jul 19 '05 #3
On Mon, 05 Apr 2004 04:37:29 GMT, "Jürgen Exner"
<ju******@hotmail.com> wrote:
Joe Cosby wrote:
When a script runs from my host's server, the working directory
doesn't appear to be the directory the script is located in.


It would be a rare coincidence indeed if the script were located in the
current working directory.
Does anyone know a way to do this?


perldoc Cwd


Thanks for the help; what I would like to be able to do though, if
possible, would be to somehow determine the path where the script is
located.

I have a directory structure like this on the server:

top page directory
- Code (directory)
---- mail.pl

That is, inside the top directory is a subdirectory "code", and inside
that is "mail.pl".

When mail.pl is called though, the working directory is the top
directory. It would be useful, for a number of tasks, to be able to
determine the location of the script within the code base.

--
Joe Cosby
http://joecosby.com/
0x29A - opcode of the beast!

Jul 19 '05 #4
Joe Cosby wrote:
what I would like to be able to do though, if possible, would be to
somehow determine the path where the script is located.


You can use $0 or $ENV{SCRIPT_FILENAME} for that.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Jul 19 '05 #5
Joe Cosby wrote:
[...]
Thanks for the help; what I would like to be able to do though, if
possible, would be to somehow determine the path where the script is
located.


perldoc FindBin

jue
Jul 19 '05 #6

foreach $reply (@responses)

thanks

blrk. I'm making jokes in Perl. That's really not a good sign.

--
Joe Cosby
http://joecosby.com/
EMBRACE the SUCKINESS

Jul 19 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Markus Dehmann | last post by:
My app reads some text files at runtime. The problem is where to find them. In my project, we agreed to rather not define own environment variables. But then, it's hard to know at runtime where...
3
by: Clift Norris | last post by:
I've created a managed C++ assembly containing a managed class that is instantiated from ASP.NET. The managed C++ assembly needs msvcp71.dll and msvcr71.dll. When ASP.NET loads the assembly, it...
7
by: Yongsub Eric Shin | last post by:
Hi. I'm just a beginner in ASP.Net. I started writing codes and I keep on getting this Runtime Error page, where it says "Description: An application error occurred on the server. The current...
11
by: Kenneth P | last post by:
Hi, This link works but when you try to download IE WebControls you'll get to page that doesn't exist. http://msdn.microsoft.com/workshop/webcontrols/overview/overview.asp Anyone who could...
21
by: Chris Durkin | last post by:
I've got an ASP.NET website on my local box, set to compile to bin\Debug and bin\Release in debug and release modes. Both directories are populated with dlls, as the solution has been compiled in...
8
by: Charts | last post by:
I download IEWebControls.exe, and installed it. Installation created IE Web Controls directory. The readme.txt said, 3. Create a /bin subdirectory for the application and copy the file...
7
by: Oenone | last post by:
I'm sure there's an obvious way to do this, but I'm missing it so far. I have an ASP.NET application that relies on several DLLs to work. Currently in order to get my site working I have to put...
2
by: graphicsxp | last post by:
Hi, How can I open all the files in a directory, which names match a particular string ? Say I have a string like 'a file name to find' and I want to find and open all the files of a given...
1
by: OrionLee | last post by:
I am using C# to work with a 3rd party DLL (Nevron Charts), and attempting to serialise it. The serialisation itself is handled somewhere inside the DLL, so to get it to happen you call the Nevron's...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.