Perl en Español

  1. Home
  2. Tutoriales
  3. Foro
  4. Artículos
  5. Donativos
  6. Publicidad
 
Índice general » Mundo Perl » Web » Error con Apache intentando ejecutar los scripts  RESUELTO Responder al tema
Nuevo tema


Página 1 de 1  [ 5 mensajes ] 
 
Nota 2009-11-19 09:19 @429
Avatar de Usuario
Perlero Nuevo
Registrado: 2009-08-26 20:01 @875
Mensajes: 9
Error con Apache intentando ejecutar los scripts
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:
Syntax: [ Download ] [ Hide ]
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, sismetic_@hotmail.com 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.


Y en el error.log:

Syntax: [ Download ] [ Hide ]
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/


y mi httpd.conf está así:

Syntax: [ Download ] [ Hide ]
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


Gracias de antemano.

_________________
La mejor religion es la verdad


Última edición por explorer el 2009-11-19 10:54 @496, editado 2 veces en total
Ortografía, ofuscación del correo


Nota 2009-11-19 09:37 @442
Avatar de Usuario
Administrador
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España
Mensajes: 10250
Re: Error Con Apache intentando ejecutar los scripts
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.


Nota 2009-11-19 09:45 @448
Avatar de Usuario
Perlero Nuevo
Registrado: 2009-08-26 20:01 @875
Mensajes: 9
Re: Error Con Apache intentando ejecutar los scripts
Ok, gracias, voy a intentarlo. ¿Cómo me aconsejarías que lo haga? ¡Ah! y este es el código de monster.cgi:

Syntax: [ Download ] [ Hide ]
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');


En mi editor de Perl funciona bien.

Uhm, lo cambié, ahora es:

Syntax: [ Download ] [ Hide ]
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


¿En Apache/cgi-bin pondría mis scripts, y en Apache/htdocs mis documentos?

_________________
La mejor religion es la verdad


Última edición por explorer el 2009-11-19 10:39 @485, editado 2 veces en total
Ortografía


Nota 2009-11-19 10:43 @488
Avatar de Usuario
Administrador
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España
Mensajes: 10250
Re: Error Con Apache intentando ejecutar los scripts  RESUELTO
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.


Nota 2009-11-20 10:59 @499
Avatar de Usuario
Perlero Nuevo
Registrado: 2009-08-26 20:01 @875
Mensajes: 9
Re: Error Con Apache intentando ejecutar los scripts
Tienes razón, ¡Dios! Qué estúpido soy, no me di cuenta. Muchas gracias :)

_________________
La mejor religion es la verdad


Responder al tema  [ 5 mensajes ] 

Reglas del Foro
No puedes abrir nuevos temas en este Foro
No puedes responder a temas en este Foro
No puedes editar tus mensajes en este Foro
No puedes borrar tus mensajes en este Foro
No puedes enviar adjuntos en este Foro

Publicidad

Socializa

Síguenos por Twitter

Suscríbete GRATUITAMENTE al Boletín de Perl en Español

Saltar a:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Traducción al español por Huan Manwë para phpbb-es.com
phpBB SEO