Re: mod perl , windows/apache problem

2003-07-29 Thread Randy Kobes
On Mon, 28 Jul 2003, Erik Browaldh wrote:

 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.
[ ... ]
 alarm(30);

As Mustafa mentioned in another reply, you might want to
try it without the flock() below [and also perhaps try without
the alarm() call above]. Also, any messages in the error
log would be helpful.

[ ... ]
 open T,log-file.txt || die cant open T for write $!;
 flock T,2; # write lock
[ ... ]
 open (T,log-file.txt) || die Cant open file T for read $!;
 flock T,1;

As Stas explained in another thread today, the directory
in which these files have been opened may not be the one
in which your script resides. Try giving the full path to
any files you're opening.

-- 
best regards,
randy kobes


Re: mod perl , windows/apache problem

2003-07-29 Thread Stas Bekman
Randy Kobes wrote:
On Mon, 28 Jul 2003, Erik Browaldh wrote:


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.
[ ... ]

alarm(30);


As Mustafa mentioned in another reply, you might want to
try it without the flock() below [and also perhaps try without
the alarm() call above]. Also, any messages in the error
log would be helpful.
[ ... ]

open T,log-file.txt || die cant open T for write $!;
flock T,2; # write lock
[ ... ]

open (T,log-file.txt) || die Cant open file T for read $!;
flock T,1;


As Stas explained in another thread today, the directory
in which these files have been opened may not be the one
in which your script resides. Try giving the full path to
any files you're opening.
and Colin will post shortly a workaround until we provide an in-core solution.

__
Stas BekmanJAm_pH -- Just Another mod_perl Hacker
http://stason.org/ mod_perl Guide --- http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


mod perl , windows/apache problem

2003-07-28 Thread Erik Browaldh
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: C:/WEB/Apache/projects/perl)
open T,log-file.txt || die cant open T for write $!;
flock T,2; # write lock
print T $l_name . \n; #concat: whiteSPACE
close T;
}
print Content-Type:text/html\n\n;

#reading from same file (ie C:/WEB/Apache/projects/perl)
open (T,log-file.txt) || die Cant open file T for read $!;
flock T,1;
while ($row=T){
  $tagdata=$tagdata . $row;#all txt-data inlst i en variabel!
}
close T;
@tuples=split(/\n/,$tagdata);# split w.r.t  whitespace
$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,C:/WEB/Apache/projects/perl/plot_txt.html) || die Cant open $!;
flock F,1;
while ($row=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;