controlling the cwd

C

Colvin

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
 
W

Walter Roberson

: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.
 
G

Gunnar Hjalmarsson

Colvin said:
I'm using Perl to write a CGI script, ...

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

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.
 
G

gnari

Colvin said:
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
 
G

Gunnar Hjalmarsson

gnari said:
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).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top