Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com Reply-To: Cygwin List Message-Id: <6.1.0.6.0.20041006203336.03fc9628@pop.prospeed.net> X-Sender: Date: Wed, 06 Oct 2004 20:36:33 -0400 To: "David A. Rogers" , cygwin AT cygwin DOT com From: Larry Hall Subject: Re: Fix: Socket problem w/ apache & perl cgi (fwd) In-Reply-To: References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Yup, that's a known issue. It's not actually Cygwin that requires the 'SYSTEMROOT' environment variable setting. It's winsock. :-( Larry At 04:05 PM 10/6/2004, you wrote: >A couple of months ago I reported a problem trying to use Apache and perl >for web development. The problem was that all attempts to use any kind of >a socket failed. > >I just got this note from Eric Davis. He's worked out the problem and a >work-around. > >He asked me to forward this to the mailing list as he is not subscribed. > >dar > > > > >---------- Forwarded message ---------- >Date: Wed, 6 Oct 2004 12:18:29 -0700 >From: Eric Davis >To: darogers AT speakeasy DOT net >Cc: edavis AT foobargeek DOT com >Subject: Fix: Socket problem w/ apache & perl cgi > > >Hi David, > >I came across your post on the Cygwin mailing list about Perl/CGI not >working under Apache. > > http://www.cygwin.com/ml/cygwin/2004-07/msg01080.html > >Like you, I was also pulling my hair out on this and figured out the >problem/solution. I verified that the problem exists and the solution >works for both the Apache and Boa web servers. > >The following CGI script works from the bash prompt but fails as a >CGI program (name - proto_real.cgi): > > #!/usr/bin/perl > > print "Content-Type: text/html\r\n\r\n\n\n\n"; > > my $num; > (undef, undef, $num) = getprotobyname('tcp'); > > if ($num) > { > print "OK: tcp($num)
\n"; > } > else > { > print "ERROR
\n"; > } > > print "\n\n"; > > >The problem has to do with (good) Web servers removing all the existing >environment variables before a fork and exec of the CGI script, and of >course building new environment variables containing all the CGI data. >For some reason, Cygwin requires the SYSTEMROOT environment variable to >be set for things to work properly. > >The fix (i.e. without modifying any Web server CGI code) is to create >a wrapper around the real script. This wrapper simply sets the >SYSTEMROOT environment variable and executes the real script. Here >is an example wrapper (name - proto.cgi): > > #!/usr/bin/perl > > $ENV{SYSTEMROOT} = "C:\\WINDOWS"; > > exec 'proto_real.cgi' > > >That should do it. With this, I can now write CGI code using Apache >or Boa under the Cygwin environment. So using DBI, DBD::mysql, >DBD::mysqlPP, IO::Socket, etc, now works as expected... all of which >I have used/tested under Cygwin/Apache/Perl/CGI. > >Lastly, could you please post this as a reply to your original question >on the Cygwin mailing list. I'm not on that list and don't want to >subscribe just to post this. > >Good luck! > >- eric > >-- > Eric Davis > http://www.foobargeek.com > > > >-- >Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple >Problem reports: http://cygwin.com/problems.html >Documentation: http://cygwin.com/docs.html >FAQ: http://cygwin.com/faq/ -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/