in reply to Having trouble with a Discussion Board

Based on your information, I'd say this line is the culprit:

open(TEMPFILE,">$tempfile") || die "Can't find this temporary file what is wrong. \n";

This basically says, open $tempfile for (over)writing, or stop (die). The error message is not very helpful though, for I bet it's a file permissions problem ;) $tempfile is defined as:

$tempfile="c:\\webserver\\osarr.org\\www\\member\\bboard\\bb.html";

And later on I read:

rename("$tempfile", "$bbfile");

So, basically, your script opens a file ($tempfile), writes something to it, and renames it to $bbfile. After that, (when the script runs again) $tempfile is gone (you already renamed it) so Perl tries to make a new file, which probably fails due to the lack of permissions. Make sure that the user under which the web-server runs, has write permissions in c:\webserver\osarr.org\www\member\bboard\

To double check this permissions problem, you might want to change the not-so-helpful error message into something like:

open(TEMPFILE,">$tempfile") || die("Can't open $tempfile: $!");

HTH

--
b10m

All code is usually tested, but rarely trusted.

Replies are listed 'Best First'.
Re: Re: Having trouble with a Discussion Board
by Ineedhelpplease (Novice) on Jan 28, 2004 at 22:06 UTC
    Thank you - I changed it and the error message I got was: Can't open : No such file or directory at c:\webserver\osarr.org\www\cgi-bin\bb.pl line 67. which is this line: $tempfile="c:\\webserver\\osarr.org\\www\\member\\bboard\\bbtemp.html"; I checked with the hosting co. and they said that the permissions are set read and write. Do I also need execute set on? Thanks What does this mean?
      the error message I got was: Can't open : No such file or directory at c:\webserver\osarr.org\www\cgi-bin\bb.pl line 67.

      If you took my code (altered die statement) and pasted it in your script verbatim, than you experience something odd, for it doesn't return the value of the $tempfile variable in the die statement, alas, it looks like either you made a typo somewhere, or $tempfile is not set right. I take it this is a script you fetched from some online source, but if you're willing to improve it a little (call that a bunch) you might want to look into strict to prevent typos.

      Looking at your original code again, I now notice (either I missed it before, or you changed it in the meanwhile) the following, which doesn't make much sense to me:

      $bbfile="c:\\webserver\\osarr.org\\www\\member\\bboard\\bb.html"; $tempfile="c:\\webserver\\osarr.org\\www\\member\\bboard\\bb.html"; [...] rename("$bbfile", "$bbfile.old"); rename("$tempfile", "$bbfile");

      This is not going to work. Both $bbfile and $tempfile point to the same file. The first rename function, changes bb.html into bb.html.old, leaving $tempfile clueless, for the file bb.html is gone. Try changing the value of $tempfile to something like:

      $tempfile="c:\\webserver\\osarr.org\\www\\member\\bboard\\bb.html.tmp" +;
      which is this line: $tempfile="c:\\webserver\\osarr.org\\www\\member\\bboard\\bbtemp.html";

      No, the line number returned, will most likely point to:

      open(TEMPFILE,">$tempfile") || die("Can't open $tempfile: $!");

      That line contains the die statement that killed your script, if I recall correctly. I also wonder why the file in $tempfile is bbtemp.html now again. It doesn't show that in your original code, as discussed above.

      I checked with the hosting co. and they said that the permissions are set read and write. Do I also need execute set on? Thanks What does this mean?

      I'm not very familiar with the Windows file system, so other monks can probably explain this in greater detail, but if it's anything like a *NIX file system, you will need executable rights on all the directories leading to the file in question:

      c:\webserver\ c:\webserver\osarr.org\ c:\webserver\osarr.org\www\ c:\webserver\osarr.org\www\member\ c:\webserver\osarr.org\www\member\bboard\

      Then you need write access to the c:\webserver\osarr.org\www\member\bboard\ directory. Not the specific file, but the entire directory, for it seems that this script will recreate the $tempfile every time. Also make sure that the web-server is able to write to that directory, not just you, using your own account. The hosting company should know this and how to set it all up, so that's their burden ;) Also make sure these directories actually exist, and you didn't make a typo in them.

      So, now back to the new error message (excuse me for the long post but I try to cover as much as possible) Can't open : No such file or directory at c:\webserver\osarr.org\www\cgi-bin\bb.pl line 67. Please triple check what line 67 exactly is and post that line specifically as you have it. The error you get looks to me like your code looks something like:

      open(TEMPFILE, "$tempfile") || die("Can't open $tmpfile: $!");

      Please not the > sign in my example, and check the spelling of the $tempfile in the die statement.

      --
      b10m

      All code is usually tested, but rarely trusted.
        Hi - I realized a posted an error on the original code that I sent you but have since fixed it and am still not getting this thing to work. The setting of $tempfile statement should read: $tempfile="c:\\webserver\\osarr.org\\www\\member\\bboard\\bbtemp.html"; Also, line 67 in my code reads as: open(TEMPFILE,">$tempfile") || die ("Can't open $tempfile: $!"); Again, I appreciate your help in this. As you probably know, I am not a perl expert and if you have any suggestions or a better and easier script for a simple discussion board, I would love to hear about them. Thank you again.