Nik has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: 2 perl cgi little problems!
by blue_cowdawg (Monsignor) on Feb 08, 2004 at 16:06 UTC

        the above code is correct because it run well on my xp system and on the remote web server with no problem. why not on my locl linux box as well? thank you folks!

    Dear Gentle Monk,
    First off let me comment that one of the tools that I use all the time when debugging code prior to its release into production is:

    use CGI::Carp qw/ fatalsToBrowser /;
    The information that will emit to your browser when something terrible goes wrong can often save you lots of aggravation later on.

    It should be stressed, however, that you would modify the CGI::Carp invocation prior to release to production to remove the qw/ fatalsToBrowser / line and let fatal errors got to you server's logs instead.

    If you haven't read it already check out CGI Help Guide as it has some good dope in it as well as far as troubleshooting errant CGI scripts.

    Offhand from what little code you have provided for us to look at I'd say it was a pathing issue. I am particularly suspicious of the line:

    @files = <../data/texts/*.txt>;
    Relative paths can trip you up time and time again.


    Peter L. Berghold -- Unix Professional
    Peter at Berghold dot Net
       Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: 2 perl cgi little problems!
by Joost (Canon) on Feb 08, 2004 at 13:51 UTC
    You probably have your paths mixed up.
    • Can you request the images in your browser using http://localhost/data/images/night.jpg ? (This is assuming your cgi-bin url is http://localhost/cgi-bin/)
    • Can you run the script on your web server from the command line? What's the output?
    • Which line is /var/www/cgi-bin/index.pl line 30 ?
Re: 2 perl cgi little problems!
by Berik (Sexton) on Feb 08, 2004 at 13:59 UTC
    Well, my guess is that when you put in
    -background=>"/data/images/night.jpg"
    it'll work fine. This is because the
    client side (the browser) doesn't know
    about you remote side paths. It will ask for
    '../data/im..' while if you ask your http
    server, the image is located at '/data/im..'.
    Check your webserver's documentation for more info

    I can't help you with the software error, as I
    can't see what's line 30, and you didn't give us
    the full error message. You should check your
    webserver's log and paste all the output regarding
    your script. Putting use warnings; above
    your script will also make your script more verbose.

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: 2 perl cgi little problems!
by MCS (Monk) on Feb 08, 2004 at 15:58 UTC

    I have a few things for you to try, first, instead of using a relative path (../) use an absolute path "/data/images/night.jpg" Assuming /var/www/ is your web root directory, this should work. The other thing to check is the file permissions (make sure it's +r). If you uploaded it via ftp, there is a chance that it's not readable.

    Again, is your data in "/var/www/cgi-bin/data/texts/" ? Or is this data the same /var/www/data directory? If so, you need to change your paths.

    If something is working on the machine you develop on (windows or linux) and it doesn't work when you upload it, the first things to check are your paths and your permissions.

    A reply falls below the community's threshold of quality. You may see it by logging in.