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

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

  3. If the script you wrote does not do what you expect it to do, you'd
    better modify it.
     
    Gunnar Hjalmarsson, Jan 19, 2004
    #3
  4. Colvin

    gnari Guest

    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. The cgi-bin folder is hopefully not readable from the web, so c) does
    probably not work. Don't know about d).
     
    Gunnar Hjalmarsson, Jan 20, 2004
    #5
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.