delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/06/20:38:39

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 <cygwin AT cygwin DOT com>
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" <darogers AT speakeasy DOT net>, cygwin AT cygwin DOT com
From: Larry Hall <lh-no-personal-replies-please AT cygwin DOT com>
Subject: Re: Fix: Socket problem w/ apache & perl cgi (fwd)
In-Reply-To: <Pine.WNT.4.50.0410061501590.3308-100000@Thor>
References: <Pine DOT WNT DOT 4 DOT 50 DOT 0410061501590 DOT 3308-100000 AT Thor>
Mime-Version: 1.0

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 <edavis AT foobargeek DOT com>
>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<html>\n<head></head>\n<body>\n";
>
>  my $num;
>  (undef, undef, $num) = getprotobyname('tcp');
>
>  if ($num)
>  {
>      print "OK: tcp($num)<br/>\n";
>  }
>  else
>  {
>      print "ERROR<br/>\n";
>  }
>
>  print "</body>\n</html>\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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019