You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Dan Östberg <je...@gmail.com> on 2015/04/19 17:01:48 UTC

[users@httpd] Apache24, Perl 5.010, MySQL 5.6 and Windows 8.1 - no database connection

Everything works (It works!) except for running cgi/pl-files where database
connection are involved. A typical Apache server error message is
"
[Sun Apr 19 15:11:03.324060 2015] [cgi:error] [pid 3312:tid 1032] (9)Bad
file descriptor: [client ::1:49681] AH01222: don't know how to spawn child
process: C:/Apache24/cgi-bin/DBIcreatetable.pl
"
HELP!

Re: [users@httpd] Apache24, Perl 5.010, MySQL 5.6 and Windows 8.1 - no database connection

Posted by Dan Östberg <je...@gmail.com>.
Dear Jeff:-) As you can see from the the files below I've changed the
scriptinpretersource.
Are there any updates of httpd.conf that I shall do? DBIcreatetable.pl
doesn't run but printenv.pl does:
DBIcreatetable.pl:
"
#!C:\Dwimperl\perl\bin\perl.exe
use 5.010;
use strict;
use warnings;

use DBI;

print "Content-type: text/plain; charset=iso-8859-1\n\n";
say "Perl MySQL Create Table Demo";

# MySQL database configurations
my $dsn = "DBI:mysql:clients";
my $username = "root";
my $password = "pw";

# connect to MySQL database
my %attr = (PrintError=>0, RaiseError=>1);

my $dbh = DBI->connect($dsn,$username,$password, \%attr);

# create table statements
my @ddl =     (
 # create tags table
 "CREATE TABLE tags (
 tag_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 tag varchar(255) NOT NULL
         ) ENGINE=InnoDB;",
        # create links table
        "CREATE TABLE links (
   link_id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
   title varchar(255) NOT NULL,
   url varchar(255) NOT NULL,
   target varchar(45) NOT NULL
 ) ENGINE=InnoDB;",
 # create link_tags table
 "CREATE TABLE link_tags (
   link_id int(11) NOT NULL,
   tag_id int(11) NOT NULL,
   PRIMARY KEY (link_id,tag_id),
   KEY fk_link_idx (link_id),
   KEY fk_tag_idx (tag_id),
   CONSTRAINT fk_tag FOREIGN KEY (tag_id)
      REFERENCES tags (tag_id),
   CONSTRAINT fk_link FOREIGN KEY (link_id)
 REFERENCES links (link_id)
 ) ENGINE=InnoDB"
        );

# execute all create table statements
for my $sql(@ddl){
  $dbh->do($sql);
}

say "All tables created successfully!";

# disconnect from the MySQL database
$dbh->disconnect();
"
printenv.pl:
"
#!C:\Dwimperl\perl\bin\perl.exe
#

# To permit this cgi, replace # on the first line above with the
# appropriate #!/path/to/perl shebang, and on Unix / Linux also
# set this script executable with chmod 755.
#
# ***** !!! WARNING !!! *****
# This script echoes the server environment variables and therefore
# leaks information - so NEVER use it in a live server environment!
# It is provided only for testing purpose.
# Also note that it is subject to cross site scripting attacks on
# MS IE and any other browser which fails to honor RFC2616.

##
##  printenv -- demo CGI program which just prints its environment
##
use strict;
use warnings;

print "Content-type: text/plain; charset=iso-8859-1\n\n";
foreach my $var (sort(keys(%ENV))) {
    my $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}
"



2015-04-19 18:22 GMT+02:00 Jeff Trawick <tr...@gmail.com>:

>  On 04/19/2015 11:01 AM, Dan Östberg wrote:
>
> Everything works (It works!) except for running cgi/pl-files where
> database connection are involved. A typical Apache server error message is
> "
> [Sun Apr 19 15:11:03.324060 2015] [cgi:error] [pid 3312:tid 1032] (9)Bad
> file descriptor: [client ::1:49681] AH01222: don't know how to spawn child
> process: C:/Apache24/cgi-bin/DBIcreatetable.pl
> "
> HELP!
>
>              Expect this to be a simple issue of running Perl scripts as
> CGIs, and nothing to do with database connections.
>
> Please have a look at this documentation and see if it helps:
> http://httpd.apache.org/docs/2.4/mod/core.html#scriptinterpretersource
>
>
>

Re: [users@httpd] Apache24, Perl 5.010, MySQL 5.6 and Windows 8.1 - no database connection

Posted by Dr James Smith <js...@sanger.ac.uk>.
Dan,

The #! line has to be the first line - so it's being ignored... remove 
the ##! line at the start and see what happens.

James

On 19/04/2015 18:28, Dan Östberg wrote:
> Dear Jeff:-) As you can see from the enclosed files I've changed the 
> scriptinpretersource.
> Are there any updates of httpd.conf that I shall do? DBIcreatetable.pl 
> doesn't run but printenv.pl <http://printenv.pl> does....
>
>
> 2015-04-19 18:22 GMT+02:00 Jeff Trawick <trawick@gmail.com 
> <ma...@gmail.com>>:
>
>     On 04/19/2015 11:01 AM, Dan Östberg wrote:
>>     Everything works (It works!) except for running cgi/pl-files
>>     where database connection are involved. A typical Apache server
>>     error message is
>>     "
>>     [Sun Apr 19 15:11:03.324060 2015] [cgi:error] [pid 3312:tid 1032]
>>     (9)Bad file descriptor: [client ::1:49681] AH01222: don't know
>>     how to spawn child process: C:/Apache24/cgi-bin/DBIcreatetable.pl
>>     "
>>     HELP!
>>     /
>>     /
>     Expect this to be a simple issue of running Perl scripts as CGIs,
>     and nothing to do with database connections.
>
>     Please have a look at this documentation and see if it helps:
>     http://httpd.apache.org/docs/2.4/mod/core.html#scriptinterpretersource
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org



---
This email has been checked for viruses by Avast antivirus software.
http://www.avast.com



-- 
 The Wellcome Trust Sanger Institute is operated by Genome Research 
 Limited, a charity registered in England with number 1021457 and a 
 company registered in England with number 2742969, whose registered 
 office is 215 Euston Road, London, NW1 2BE. 

Re: [users@httpd] Apache24, Perl 5.010, MySQL 5.6 and Windows 8.1 - no database connection

Posted by Dan Östberg <je...@gmail.com>.
Dear Jeff:-) As you can see from the enclosed files I've changed the
scriptinpretersource.
Are there any updates of httpd.conf that I shall do? DBIcreatetable.pl
doesn't run but printenv.pl does....


2015-04-19 18:22 GMT+02:00 Jeff Trawick <tr...@gmail.com>:

>  On 04/19/2015 11:01 AM, Dan Östberg wrote:
>
> Everything works (It works!) except for running cgi/pl-files where
> database connection are involved. A typical Apache server error message is
> "
> [Sun Apr 19 15:11:03.324060 2015] [cgi:error] [pid 3312:tid 1032] (9)Bad
> file descriptor: [client ::1:49681] AH01222: don't know how to spawn child
> process: C:/Apache24/cgi-bin/DBIcreatetable.pl
> "
> HELP!
>
>              Expect this to be a simple issue of running Perl scripts as
> CGIs, and nothing to do with database connections.
>
> Please have a look at this documentation and see if it helps:
> http://httpd.apache.org/docs/2.4/mod/core.html#scriptinterpretersource
>
>
>

Re: [users@httpd] Apache24, Perl 5.010, MySQL 5.6 and Windows 8.1 - no database connection

Posted by Jeff Trawick <tr...@gmail.com>.
On 04/19/2015 11:01 AM, Dan Östberg wrote:
> Everything works (It works!) except for running cgi/pl-files where 
> database connection are involved. A typical Apache server error 
> message is
> "
> [Sun Apr 19 15:11:03.324060 2015] [cgi:error] [pid 3312:tid 1032] 
> (9)Bad file descriptor: [client ::1:49681] AH01222: don't know how to 
> spawn child process: C:/Apache24/cgi-bin/DBIcreatetable.pl
> "
> HELP!
> /
> /
Expect this to be a simple issue of running Perl scripts as CGIs, and 
nothing to do with database connections.

Please have a look at this documentation and see if it helps: 
http://httpd.apache.org/docs/2.4/mod/core.html#scriptinterpretersource