• Publicidad

Error con Apache intentando ejecutar los scripts

Todo lo relacionado con el desarrollo Web con Perl: desde CGI hasta Mojolicious

Error con Apache intentando ejecutar los scripts

Notapor Sismetic » 2009-11-19 09:19 @429

Bajé Apache y lo instalé, y lo configuré (según yo :P)

Me ejecuta sin problema PHP y HTML, pero en cuanto los CGI scripts no me los ejecuta. Me muestra:
Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


Y en el error.log:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
[Thu Nov 19 08:10:25 2009] [error] [client XXX] (OS 2)The system cannot find the file specified.  : couldn't spawn child process: G:/Naty/Perl/monster.cgi, referer: http://localhost/
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


y mi httpd.conf está así:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
ServerRoot "G:/Naty/Apache"

DocumentRoot "G:/Naty/Perl/"

<Directory "G:/Naty/Perl/">

    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all

</Directory>

    ScriptAlias /cgi-bin/ "G:/Naty/Perl/"

<Directory "G:/Naty/Perl/">
    AllowOverride None
    Options +ExecCGI -includes
    Order allow,deny
    Allow from all
</Directory>

    AddHandler cgi-script .cgi .pl
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


Gracias de antemano.
Última edición por explorer el 2009-11-19 10:54 @496, editado 2 veces en total
Razón: Ortografía, ofuscación del correo
La mejor religion es la verdad
Avatar de Usuario
Sismetic
Perlero nuevo
Perlero nuevo
 
Mensajes: 9
Registrado: 2009-08-26 20:01 @875

Publicidad

Re: Error Con Apache intentando ejecutar los scripts

Notapor explorer » 2009-11-19 09:37 @442

Sería interesante ver las primeras líneas de Monster.cgi.

En cuanto al httpd.conf, no me gusta nada... está repetido dos veces la definición del directorio G:/Naty/Perl/.

Además, hay errores que a mí me parecen muy graves... por ejemplo, ServerRoot es el lugar donde están los ficheros de configuración del servidor web, pero al mismo tiempo vemos que es igual que el DocumentRoot, el lugar donde residen los ficheros que van a salir al exterior. Y el mismo en donde pedimos que se ejecuten los cgi...

Yo empezaría con un httpd.conf nuevo. Hacer que funcione el servicio web normal, y luego activar los cgi. Por defecto, los httpd.conf vienen con

ScriptAlias /cgi-bin/ "G:/Naty/Perl/cgi-bin"

por lo que solo tendríamos que meter los cgi en esa carpeta, y agregar cgi-bin al URL para invocarlos.
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Error Con Apache intentando ejecutar los scripts

Notapor Sismetic » 2009-11-19 09:45 @448

Ok, gracias, voy a intentarlo. ¿Cómo me aconsejarías que lo haga? ¡Ah! y este es el código de monster.cgi:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!C/Perl/bin/perl.exe
  2.  
  3. use warnings;
  4. use strict;
  5. use CGI;
  6. use HTML::Template;
  7. use Data::Dumper;
  8. sub Monster_Name{
  9.  
  10.    my $file = 'mon.txt';
  11.    open my $FILE , '<' , $file or die ("Could not open file $file");
  12.    my @monster_data = <$FILE>;
  13.    close $FILE;
  14.  
  15.    my @monster;
  16.    for my $data(@monster_data){
  17.  
  18.       chomp $data;
  19.       my ($name,$hp,$att,$m_att) = split (',',$data);
  20.       push @monster,$name;
  21.  
  22.    }
  23.  
  24.    shift @monster;
  25.    return @monster;
  26.  
  27. }
  28.  
  29. sub Char{
  30.  
  31.    my @char = @_;
  32.    return @char;
  33.  
  34. }
  35.  
  36. sub Get_Monster{
  37.  
  38.    my $self = shift;
  39.    my $attack;
  40.    my $defense;
  41.    my $hp;
  42.    if ($self eq 'Strong'){
  43.  
  44.       $attack = Rand_Num(150);
  45.       $defense = Rand_Num(100);
  46.       $hp = Rand_Num(300);
  47.  
  48.    }
  49.    elsif($self eq 'Dangerous'){
  50.  
  51.       $attack = Rand_Num(500);
  52.       $defense = Rand_Num(200);
  53.       $hp = Rand_Num(1000);
  54.  
  55.    }
  56.    else{
  57.  
  58.       $attack = Rand_Num(50);
  59.       my $defense = Rand_Num(50);
  60.       my $hp = Rand_Num(100);
  61.  
  62.    }
  63.  
  64.    open my $FILE,'<','mon.txt' or die $!;
  65.    my @monsters = <$FILE>;
  66.    close $FILE;
  67.  
  68.    my $monster_numb = @monsters;
  69.    my $m_number = Rand_Num($monster_numb);
  70.    my @monster;
  71.    for my $data( @monsters){
  72.  
  73.       chomp $data;
  74.       my ($name,$hp,$att,$m_att) = split (',',$data);
  75.       push @monster,$name;
  76.  
  77.    }
  78.    my $monster = $monster[$m_number];
  79.    my @char = Char('Sismetic','500','150','30');
  80.    print "$char[0] vs $monster that has " . $attack . " attack, " . $defense . " defense and " . $hp . " hp";
  81.  
  82. }
  83.  
  84. sub Rand_Num{
  85.  
  86.    my $self = shift;
  87.    my $rand = int(rand($self));
  88.    return $rand;
  89.  
  90. }
  91.  
  92. Get_Monster('Dangerous');
Coloreado en 0.003 segundos, usando GeSHi 1.0.8.4


En mi editor de Perl funciona bien.

Uhm, lo cambié, ahora es:

Sintáxis: [ Descargar ] [ Ocultar ]
Using text Syntax Highlighting
ServerRoot "G:/Naty/Apache"
DocumentRoot "G:/Naty/Apache/htdocs"
<Directory "G:/Naty/Apache/htdocs/">
    Options Indexes FollowSymLinks ExecCGI
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

ScriptAlias /cgi-bin/ "G:/Naty/Apache/cgi-bin/"

<Directory "G:/Naty/Apache/cgi-bin/">
    AllowOverride None
    Options +ExecCGI -includes
    Order allow,deny
    Allow from all
</Directory>

AddHandler cgi-script .cgi .pl
Coloreado en 0.000 segundos, usando GeSHi 1.0.8.4


¿En Apache/cgi-bin pondría mis scripts, y en Apache/htdocs mis documentos?
Última edición por explorer el 2009-11-19 10:39 @485, editado 2 veces en total
Razón: Ortografía
La mejor religion es la verdad
Avatar de Usuario
Sismetic
Perlero nuevo
Perlero nuevo
 
Mensajes: 9
Registrado: 2009-08-26 20:01 @875

Re: Error Con Apache intentando ejecutar los scripts

Notapor explorer » 2009-11-19 10:43 @488

La primera línea es #!C/Perl/bin/perl.exe, que no es correcta. ¿Seguro que ahí está binario perl.exe? ¿No será #!C:/Perl/bin/perl.exe? (falta un ':')

El resto del programa no es un verdadero cgi: no hay devolución de las cabeceras Content-type que el servidor web espera.

Según el nuevo httpd.conf ahora sería posible acceder al cgi con http://localhost/cgi-bin/monster.cgi, y siempre que monster.cgi esté guardado en esa carpeta.
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España

Re: Error Con Apache intentando ejecutar los scripts

Notapor Sismetic » 2009-11-20 10:59 @499

Tienes razón, ¡Dios! Qué estúpido soy, no me di cuenta. Muchas gracias :)
La mejor religion es la verdad
Avatar de Usuario
Sismetic
Perlero nuevo
Perlero nuevo
 
Mensajes: 9
Registrado: 2009-08-26 20:01 @875


Volver a Web

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 0 invitados