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

The following returns "No such file or directory" when viewed in a web browser, but not when run through command-line:
#!/usr/bin/perl use CGI qw(:all); use MLDBM qw(DB_File); use Fcntl; print header; print start_html; tie(%messages, 'MLDBM', 'messages', O_CREAT|O_RDWR, 0777) || print "$! +";
What could be the problem? The permissions should be fine, to test it, I chmoded everything to 777; the script, the directory...

Replies are listed 'Best First'.
Re: Tie() doesn't work
by geektron (Curate) on Dec 30, 2000 at 06:25 UTC
    does it work as a command-line tool at all? since you're using CGI.pm you can run it from the command line, and just <cntl>+d if it doesn't require input.

    i just tried it ( after substituting GDBM_File for MLDBM, since i don't have MLDBM installed ) and it worked w/out a problem from the command line.

    now, from a browser - after setting directory permissions so that my webserver can write -

    no problem, no error message, nothing.

    maybe changing the MLDBM in the tie() to DB_File will do it.

Re: Tie() doesn't work
by ichimunki (Priest) on Dec 30, 2000 at 06:22 UTC
    If this is your server you should be able to handle reads and write more effectively than chmod 777. For some reason the phrase "world writable" is setting off alarms in my head.

    If this is not your server, keep in mind that they may be using chroot which may change your default directory. Try a test script that prints out cwd and pwd and lists files it can see in "." to get a sense of what your CGI process thinks is the default directory.
Re: Tie() doesn't work
by eg (Friar) on Dec 30, 2000 at 06:03 UTC

    Maybe the script is being run from a different directory? Try chdir or using the full filename + path.

      nope, same dir.

        I suspect you misunderstood the question. How did you verify that the script is running from the same directory? We aren't talking about the directory that the script resides in, but what the current working directory is when the script is run, which is why chdir was mentioned.

                - tye (but my friends call me "Tye")