Hello everyone!
I have written a program that takes argument from html-formula and read and
write it to a textfile.
When I tried it with perl mod 2, under windows with
apache it doesnt work anymore.
No new entries are written to the log-file.txt
Ive tried chmod, especially r/w accesses
but that doesnt seem to help.
also, .cgi files is renamed as .pl and the first line #!/usr/bin/perl -w
is deleted.
Maybe some configurations are wrong?
More comments are followed in the code below.
Under Linux, Apache this program works
Greatful for helps
Erik
alarm(30);
$POST_MAX=5000;
use CGI::Carp qw(fatalsToBrowser);
use CGI':standard';
use POSIX 'strftime';
($Second, $Minute, $Hour, $Day, $Month, $Year, $WeekDay, $DayOfYear,
$IsDST) = localtime(time);
#get name and message from HTML-formular
$l_name=param('by'); # name
$l_mess=param('mess'); # message
if ($l_name eq ""){ #nothing written in HTML-formula?
}
else{ #otherwise write name and message last in file
#(file path is: >log-file.txt" || die "cant open T for write $!";
flock T,2; # write lock
print T $l_name . "\n"; #concat:
close T;
}
print "Content-Type:text/html\n\n";
#reading from same file (ie C:/WEB/Apache/projects/perl)
open (T,"){
$tagdata=$tagdata . $row;#all txt-data inlst i en variabel!
}
close T;
@tuples=split(/\n/,$tagdata);# split w.r.t
$name4=$tuples[0]; #I just want to save the last 4 messages in the file
$name3=$tuples[1];
$name2=$tuples[2];
$name1=$tuples[3];
$tmp_nam=$tuples[4];
if($l_name eq ""){ #IF nothing is written in the HTML-formula, THEN
$name4=$tuples[0]; #take old information
$name3=$tuples[1];
$name2=$tuples[2];
$name1=$tuples[3];
}
else{ #else "move up" information (ie only saving last 4 entries)
$name4=$name3;
$name3=$name2;
$name2=$name1;
$name1=$tmp_nam;
}
# for html-document in the same directory as perl-script, I now had to set
#the whole path, which wasnt necessary under Linux/Apache.
open (F,"){
$row=~s//eval$1/eg; #substitution in html-doc
print $row;
}
close F;
#this file also lies under C:/WEB/Apache/projects/perl
open T,">log-file.txt" || die "cant open T for write $!";
flock T,2; # skrivls
print T $name4 . "\n";
print T $name3 . "\n";
print T $name2 . "\n";
print T $name1 . "\n";
close T;