Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > controlling the cwd

Reply
Thread Tools

controlling the cwd

 
 
Colvin
Guest
Posts: n/a
 
      01-19-2004
I'm using Perl to write a CGI script, and for the most part it works.
My directory structure looks like the following:

/webfolder/*.html
/webfolder/images/*.jpeg
/webfolder/js/*.js
/webfolder/cgi-bin/*.pl

My current design loads the html files into scalar variables, performs
some regex manipulation, and then outputs the (modified) scalar to the
browser. The problem is that all of the references to images/*.jpeg are
getting changed to cgi-bin/images/*.jpeg I tried inserting a chdir ".."
into the Perl scripts, but that only changed the cwd of the script and
not the cwd of the html. What's the best way to solve this?

Thank you,
Alec Colvin

 
Reply With Quote
 
 
 
 
Walter Roberson
Guest
Posts: n/a
 
      01-19-2004
In article <>, Colvin <> wrote:
:I'm using Perl to write a CGI script, and for the most part it works.
:My directory structure looks like the following:

:My current design loads the html files into scalar variables, performs
:some regex manipulation, and then outputs the (modified) scalar to the
:browser. The problem is that all of the references to images/*.jpeg are
:getting changed to cgi-bin/images/*.jpeg I tried inserting a chdir ".."
:into the Perl scripts, but that only changed the cwd of the script and
:not the cwd of the html. What's the best way to solve this?

Sounds like perhaps you should set a base document in your HTML.
Alternately, use your regex's to change the paths to absolute paths
instead of relative.
--
I've been working on a kernel
All the livelong night.
I've been working on a kernel
And it still won't work quite right. -- J. Benson & J. Doll
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-19-2004
Colvin wrote:
> I'm using Perl to write a CGI script, ...


<snip>

> My current design loads the html files into scalar variables,
> performs some regex manipulation, and then outputs the (modified)
> scalar to the browser. The problem is that all of the references
> to images/*.jpeg are getting changed to cgi-bin/images/*.jpeg


<snip>

> What's the best way to solve this?


If the script you wrote does not do what you expect it to do, you'd
better modify it.

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

 
Reply With Quote
 
gnari
Guest
Posts: n/a
 
      01-20-2004
"Colvin" <> wrote in message
news:...
> I'm using Perl to write a CGI script, and for the most part it works.
> My directory structure looks like the following:
>
> /webfolder/*.html
> /webfolder/images/*.jpeg
> /webfolder/js/*.js
> /webfolder/cgi-bin/*.pl
>
> My current design loads the html files into scalar variables, performs
> some regex manipulation, and then outputs the (modified) scalar to the
> browser. The problem is that all of the references to images/*.jpeg are
> getting changed to cgi-bin/images/*.jpeg I tried inserting a chdir ".."
> into the Perl scripts, but that only changed the cwd of the script and
> not the cwd of the html. What's the best way to solve this?


several ways. among them:
a) skip the silly cgi-bin directory and keep your *.pl files
in webfolder/
b) fix the html output to point at the correct location
c) keep the images that the *.pl refer to in cgi-bin/images/
d) make a symbolic link between images/ and cgi-bin/images/

I would go for a)

gnari





 
Reply With Quote
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      01-20-2004
gnari wrote:
> "Colvin" <> wrote in message
> news:...
>> The problem is that all of the references to images/*.jpeg are
>> getting changed to cgi-bin/images/*.jpeg I tried inserting a
>> chdir ".." into the Perl scripts, but that only changed the cwd
>> of the script and not the cwd of the html. What's the best way
>> to solve this?

>
> several ways. among them:
> a) skip the silly cgi-bin directory and keep your *.pl files in
> webfolder/
> b) fix the html output to point at the correct location
> c) keep the images that the *.pl refer to in cgi-bin/images/
> d) make a symbolic link between images/ and cgi-bin/images/


The cgi-bin folder is hopefully not readable from the web, so c) does
probably not work. Don't know about d).

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
subprocess cwd keyword. Ivan Vinogradov Python 3 10-27-2006 02:42 PM
Where is can set an aspnet unix-like cwd analog for whole application? Burganovsky ASP .Net 1 12-15-2005 10:19 AM
Where is can set an aspnet unix-like cwd analog for whole application? Burganovsy ASP .Net 0 12-11-2005 07:00 PM
More elegant way to cwd? Kamilche Python 11 12-29-2004 02:52 AM
popen pipes fail when cwd is a UNC path Tim Black Python 2 09-09-2004 05:53 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57