controlling the cwd

Discussion in 'Perl Misc' started by Colvin, Jan 19, 2004.

  1. Colvin

    Colvin Guest

    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
     
    Colvin, Jan 19, 2004
    #1
    1. Advertising

  2. 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
     
    Walter Roberson, Jan 19, 2004
    #2
    1. Advertising

  3. 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
     
    Gunnar Hjalmarsson, Jan 19, 2004
    #3
  4. Colvin

    gnari Guest

    "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
     
    gnari, Jan 20, 2004
    #4
  5. 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
     
    Gunnar Hjalmarsson, Jan 20, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Burganovsky
    Replies:
    1
    Views:
    468
    Mark Rae
    Dec 15, 2005
  2. Burganovsy
    Replies:
    0
    Views:
    460
    Burganovsy
    Dec 11, 2005
  3. Tim Black
    Replies:
    2
    Views:
    476
    Steve Christensen
    Sep 9, 2004
  4. Kamilche

    More elegant way to cwd?

    Kamilche, Dec 24, 2004, in forum: Python
    Replies:
    11
    Views:
    517
    Peter Hansen
    Dec 29, 2004
  5. Ivan Vinogradov

    subprocess cwd keyword.

    Ivan Vinogradov, Oct 26, 2006, in forum: Python
    Replies:
    3
    Views:
    358
    Ivan Vinogradov
    Oct 27, 2006
Loading...

Share This Page