Firstly, I apologize for the multiple questions I am posting, but you guys
are being great help...
Ok here comes the problem...
One of my perl cgi scripts is calling a cli program , and the cli program
creates an .htm file with text and check boxes, that the users are supposed
to open through a link and do various things.
The problem is the case when many users run the perl cgi script, thus having
the cli program being called multiple times and having to write on the same
.htm file. It seems like it is a file locking problem, but how do I handdle
it in this case, since an outside process (CLIprogram.exe) is being called
with the system command?
This is sample of the code and more comments...:
#!/usr/bin/perl
#use strict;
use CGI;
my $command;
my $segment;
my $query_data;
#$segment="172.16.0.89";
read(STDIN, $query_data, $ENV{'CONTENT_LENGTH'});
my $my_query = new CGI($query_data);
my @get_query = $my_query->param;
$segment=@get_query[0];
$html= $segment . ".htm";
$command=qq(CLIprogram.exe $html);
system($command) || die "could not execute";
print "<BR>";
print "<a href=\"..\\wwwroot\\$html\"> <b> LIST </b> </a>";
I tried using flock, as shown below, but I would get an error( "The file is
being used by another process") when the script was about the execute the
system command since I guess it thinks that a second outside process
(CLIprogram.exe) is trying to access the $html file which has already been
created and opened with the sysopen command. Do I need to make the
CLIprogram.exe to output to a temp file, but then how do I handdle the case
of copying the temp file to the original $html file, since there will be
many users that will be doing that? :
#!/usr/bin/perl
#use strict;
use CGI;
my $command;
my $segment;
my $query_data;
read(STDIN, $query_data, $ENV{'CONTENT_LENGTH'});
my $my_query = new CGI($query_data);
my @get_query = $my_query->param;
$segment=@get_query[0];
$html= $segment . ".htm";
sysopen(FILE, "..\\wwwroot\\$html", O_CREAT | O_RDWR) or die $!;
flock(FILE, LOCK_EX) || warn $!;
$command=qq( CLIprogram.exe $html );
system($command); #|| die "could not execute";
flock(FILE, LOCK_UN) || warn $!;
sleep(5);
print "<BR>";
print "<a href=\"..\\wwwroot\\$html"> <b> LIST </b> </a>";
_______________________________________________
Perl-Win32-Web mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-web
problems with file locking .?. *please please help!*
Schiza, Apostolia (ISS Atlanta) Tue, 16 Jan 2001 15:54:45 -0800
- Re: problems with file locking .?. *please... Schiza, Apostolia (ISS Atlanta)
- Re: problems with file locking .?. *p... Ron Grabowski
