On approximately 3/31/2003 1:58 PM, came the following characters from
the keyboard of BB:
I have begun learning CGI from a book dated '96 which refers to UNIX as a
platform. I am using Win32 and have a question about an example from the
book, which I assume works on some system, just not mine, hehe.
What I do using I.E. 6.x is:
1. Enter the CGI path and filename in the browser Location field and press
the Enter key
2. Note: 'Internal Server Error' is received.
3. Apache error log says:
[error]  [client] The system cannot find the file specified.  :couldn't
spawn child process: path/trythis.cgi

I suspect the '&' but can not find a ref to this functionality on Win32 with
ActivePerl 5.8.0.805

#-----------trythis.cgi-------------
#!c/perl/bin/perl.exe
#
$data = 'C:/Apache2/Apache2/htdocs/counter.data';
$lockfile = 'C:/Apache2/Apache2/htdocs/counter.LOCK';
# main routine
print "Content-Type: text/html\n";
print "&increment";

Indeed, according to the HTTP protocol, the above line is supposed to print out an additional HTTP header, since you haven't yet terminated the headers with a blank line.


&increment

is not a valid HTTP header... so that probably leads to the internal server error.

Since "sub increment" doesn't print anything more to STDOUT, you need to at least print one more blank line, to terminate the HTTP headers.

To call the sub named "increment", you need a line that would invoke that subroutine, such as

& increment;

not a line that prints what looks like an invocation of the subroutine, such as you have.

sub increment {
  # read the data
  open(DATA,$data) || die "Can't open data file.\n";
  $accesses = ; $accesses++;
  close(DATA);
  # check for lock file
  while (-e $lockfile)
    { sleep 2; # wait 2 seconds }
  # create lockfile
  open(LOCK,">$lockfile") || die "Can't create lockfile.\n";
  close(LOCK);
  # write new value
  open(DATA,">$data");
  print DATA "$accesses\n";
  close(DATA);
  # delete lockfile unlink($lockfile);
}

Any help?

Thanks.

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs




--
Glenn
=====
If the grass is greener on the other side of the fence,
try taking better care of your own side.     -- Unknown

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to