in reply to Cannot open files using CGI

In addition to what others have said, these two lines look like a problem:
my $newRefFile = "$pathName\newRefFile.txt"; my $newBlastFile = "$pathName\newBlastFile.txt";
Those backslashes won't show up the way you expect unless you double them -- all they're doing here is inserting a newline in the strings. If $pathName is being defined the same way, the problem is compounded. I'm doubtful that this code works from the command line.

You might as well just use a plain old forward slash for separating directory names, because perl will know what you mean by that and do the Right Thing. (Or you could use the appropriate File:: module(s) to construct path names in an OS-neutral manner.)

Replies are listed 'Best First'.
Re: Cannot open files using CGI
by MonkPaul (Friar) on May 29, 2005 at 14:44 UTC
    Yes, well spotted. I had not seen that. Doh!

    With regards to the file permissions do these have to be changed when the file is uploaded to the server using e.g. O_RDRW and chmod 755.

    The server is a whack biolinux server if that helps (dont know of it matters much if its the file permissions though).

    Cheers
    MonkPaul.

      If the server that this cgi script is running on is a linux box, you damn well better not use backslashes at all in the path names for input or output files. As for setting permissions, the only thing you need to worry about is that the "user" account that is the web server has read+execute permission at each directory layer above the directory where file will be stored; and it must have read+write+execute on the storage directory.

      If the storage directory is owned by the web server user account, its permission can be 755; if it's owned by some other user, but has group ownership that matches the web server's group, then it can be 775. As for permissions on the files that are created, that's up to you.

        Ah, I seem to have hit a snag.
        Whay shouldnt i use back slashes with biolinux or linux box. Are they supposed to be forward slashes or something else (dumb question i know)?.

        MonkPaul.

Re^2: Cannot open files using CGI
by Anonymous Monk on May 30, 2005 at 12:01 UTC
    linux may allow it, but having "\n" in filenames is a bad idea