[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl-WebCGI] Q1+2: Opening/closing/flocking





Hi,

As you may recall I'm in the process of creating an interactive 
multimedia tutorial for CGI scripting using Perl. The current and second 
last chapter deals with saving data.

Question 1:
In the MacPerl tutorial I explained that it was important to close a file 
as soon as you're done with it. However, from the flock-command I 
understand that that is not enough. Now, if I flock, why bother with 
closing in time?

Question 2:
I try to save a log file using this script:

#!/usr/bin/perl5

print "Content-type: text/html\n\n";
print "<HTML>\n<HEAD>\n<TITLE>My home page</TITLE>"; 
print "\n</HEAD>\n<BODY>";
$thePath = 'utopia.knoware.nl//usr/home/bsfa/www/';
# General path, useful for constructing paths to one or more
# files (or folders). 
$theFile = '>>'."$thePath".'log.txt';
# Here we compose the full path to this particular file
open(MYLOG, $theFile);
print "$theFile";
print MYLOG "$ENV{'HTTP_USER_AGENT'}";
# This log accumulates data on the type of platform and brower.
close(MYLOG);
print "\n</BODY>\n</HTML>";

Now a file is supposed to be created when it isn't there. But none was. 
Plus, even if the file was there, nothing was written in it. 

>From one of my books I understood that a CGI can create a file, but if it 
does, even the owner can't open delete etc. it. (One would have to change 
the permissions using a CGI script to be able to do that). However, I 
don't see anything else than: owner, group + other. So, am I doing 
something wrong. Is it that my ISP doesn't allow me to use CGIs to write 
something or....?

BFN

Bert

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-webcgi-request@macperl.org