Foros del Web » Programación para mayores de 30 ;) » Programación General »

Necesito un poco de ayuda

Estas en el tema de Necesito un poco de ayuda en el foro de Programación General en Foros del Web. Hola. Necesito un poco (bastante) ayuda. Tengo q poner un cgi para mandar info a traves de un formulario normalito en un servidor en el ...
  #1 (permalink)  
Antiguo 10/06/2003, 19:07
Avatar de lantrax  
Fecha de Ingreso: abril-2003
Ubicación: Spain is different
Mensajes: 310
Antigüedad: 21 años
Puntos: 0
Necesito un poco de ayuda

Hola.

Necesito un poco (bastante) ayuda.
Tengo q poner un cgi para mandar info a traves de un formulario normalito en un servidor en el cual no saben ni ellos ( o no lo quieren decir) si es unix o windows. Vamos q lo unico q se es q tiene soporte para cgi y punto. La empresa en cuestion a la q estoy renovando la web se niega a cambiar de host, así q como el cliente siempre tiene razón, tengo q encontrar otra solución.
Básicamente: se q un cgi no funciona igual en plataforma windows q en unix. Hay alguna forma de saber q plataforma es la del host en cuention???
Una vez sabido, en que carpeta debo instalar el cgi?? en /cgi-bin/ del directorio raiz del espacio web q tiene esta empresa contratado???

Por cierto pongo aquí el codigo cgi q he voy a poner por si a alguien le puede servir, en principio es gratuito, más q nada por si hubiera que hacer modificacion segun plataforma.

Código:
#!/usr/bin/perl
##############################################################################
# Cliff's Form Mailer Version 1.0                                            # 
# Copyright 1998 Shaven Ferret Productions                                   #
# Created 6/4/98                                                             #
# Available at http://www.shavenferret.com/scripts                           #
##############################################################################
# COPYRIGHT NOTICE                                                           #
# Copyright 1998 Shaven Ferret Productions All Rights Reserved.              #
#                                                                            #
# This script can be used\modified free of charge as long as you don't       #
# change this header thing, or the part that gives me credit for writing     #
# script in the e-mail.  If you really need to remove this part, go to       #
# http://www.shavenferret.com/scripts/register.shtml .  By using this script #
# you agree to indemnifyme from any liability that might arise from its use. #
# In simple English, if this script somehow makes your computer run amuck    #
# and kill the pope, it's not my fault.                                      #
#                                                                            #
# Redistributing\selling the code for this program without prior written     #
# consent is expressly forbidden.                                            #
##############################################################################

# Enter the location of sendmail.  
$mailprogram = "/usr/lib/sendmail -t";

# Enter the fields that are required.  They should each be in quotes and
# separated by a comma.  If no fields are required, change the next line
# to @required = ();
@required = ('email','subject');

# Enter your e-mail address.  Be sure to put a \ in front of the @.
# ([email protected] becomes user\@domain.com)
$youremail = "yourname\@yourdomain.com";

##############################################################################
# Congratulations!  You've finished defining the variables.  If you want to, #
# you can continue screwing with the script, but it isn't necessary.         #
##############################################################################

# Put the posted data into variables

read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        $FORM{$name} = $value;
}

# Check for all required fields

foreach $check(@required) {
        unless ($FORM{$check}) {
                print "Content-type: text/html\n\n";
                print "<html><head><title>Missing Information</title></head>\n";
                print "<body><h1>Missing Information</h1><br>\n";
                print "I'm sorry, but it would appear that you've forgotten to\n";
                print "fill out the $check field.  Please click\n";
                print "back and try again.\n";
                print "</body></html>\n";
                exit;
        }
}

# Check the senders email

if ($FORM{'email'}) {
        unless ($FORM{'email'} =~ /\w+@\w+.\w+/) {
                print "Content-type: text/html\n\n";
                print "<html><head><title>Bad E-mail</title></head>\n";
                print "<body><h1>Bad E-mail</h1><br>The e-mail address that you've\n";
                print "entered, $FORM{'email'}, is invalid.  Please click back and\n";
                print "try again.\n";
                exit;
        }
}

open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $FORM{'email'}\n";
print MAIL "Subject: $FORM{'subject'}\n";
print MAIL "Hello.  The following information has been submitted:\n\n";
foreach $pair (@pairs) {
        ($name, $value) = split(/=/, $pair);
        $value =~ tr/+/ /;
        $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        unless ($name eq "response" || $name eq "email" || $name eq "subject") { 
                print MAIL "$name: $value\n";
        }
}
close MAIL;

if ($FORM{'response'} && $FORM{'email'}) {
        open (RESPONSE, $FORM{'response'});
        @response = <RESPONSE>;
        close(RESPONSE);
        open (MAIL,"|$mailprogram");
        print MAIL "To: $FORM{'email'}\n";
        print MAIL "From: $youremail\n";
        print MAIL "Subject: $FORM{'subject'} -- Autoresponse\n";
        foreach $line (@response) {
                print MAIL "$line";
        }
        print MAIL "The person you are communicating with is using Cliff's\n";
        print MAIL "Form Mailer Script.  If you would like to add this script\n";
        print MAIL "to your web site, you can find it and many more perl scripts at\n";
        print MAIL "http://www.shavenferret.com/scripts\n";
        close MAIL;
}

print "Content-type: text/html\n\n";
print "<html><head><title>Thank you!</title></head>\n";
print "<body><h1>Thank you!</h1><br>Thanks for your input! \n";
if ($FORM{'response'} && $FORM{'email'}) {
        print "You should receive an autoresponse shortly.<p>\n";
}
print "Please click back.\n";
Gracias y...A ver si hay suerte

Salu2

Lantrax
  #2 (permalink)  
Antiguo 11/06/2003, 07:28
 
Fecha de Ingreso: mayo-2003
Mensajes: 328
Antigüedad: 21 años
Puntos: 0
Hola Lantrax:

Creó que la forma mas rápida de saber si estas en plataforma windows o plataforma UNIX, es viendo cual es el root del servidor, o cual es el path a perl.

Si los paths enpiezan con /algo/etc/directorio entonces estas en UNIX, porque los paths de windows siempre inician con C:\ o D:\, etc.

Si el servidor esta en windows, entonces ese CGI no te va a funcionar, porque utiliza el sendmail que es un deamon de UNIX, por lo que necesitas un CGI que conecté con el SMTP, me imaginó que ha de haber algunos por ahí....

SALUDOS
  #3 (permalink)  
Antiguo 11/06/2003, 17:22
Avatar de lantrax  
Fecha de Ingreso: abril-2003
Ubicación: Spain is different
Mensajes: 310
Antigüedad: 21 años
Puntos: 0
Hola kidd.

Bueno, el problema está en q no se donde está el path del interprete de perl. Ni tampoco dicen q me pueden facilitar esa info. he hecho un telnet a ver si por lo menos me dice el sys q tiene pero me rechaza la conexion. Dicho sea de paso, solo pudeo conectarme desde una ip desterminada de salida de la pymw en cuestion. En fin, un carajal, ya te contaré.

Por cierto, el cgi q te enseñé me has dicho q como usa sendmail solo vale para unix. Si el servidor por fin descubro qu es win sabes de alguna web con srcipt de cgi gratuitos verison windows q pueda usar??

Gracias figura.

Salu2

Lantrax
  #4 (permalink)  
Antiguo 11/06/2003, 18:59
 
Fecha de Ingreso: mayo-2003
Mensajes: 328
Antigüedad: 21 años
Puntos: 0
Hola:

Hice una búsqueda en Google y encontré esta liga que tiene un script de formail que funciona con Windows:

http://www.geocel.com/windmail/library/formmail.htm

Cuando logres descubrir en que sistema operativo estas, aqui hay algunas cosas que tienes que saber extra dependiendo del Sistema Operativo:

UNIX:
- El path para perl
- El path para el programa de "sendmail"

Windows:
- La dirección del servidor smtp
- El path para perl

Estas cosas las tienes que saber, pues las tienes que configurar en el formmail, así que si los del hosting se siguen resisitiendo a darte informacion va a ser un verdadero problema.

Lo que te puedo recomendar es que le digas a tu cliente que no puedes confiar en un hosting que se niega a darte informacion de TU propio sistema. No entiendo como los administradores pueden pensar que puedes trabajar de esa manera, pero bueno...

SALUDOS
  #5 (permalink)  
Antiguo 12/06/2003, 11:23
Avatar de lantrax  
Fecha de Ingreso: abril-2003
Ubicación: Spain is different
Mensajes: 310
Antigüedad: 21 años
Puntos: 0
Hola kidd.

No te lo vasa creer. Al final les he forzado a q contestaran y rsulta q según me han dicho han tenido q desinstalar el interprete de perl del sistema en el q está la web en cuestión del cliente. Y q de momento no tienen ninguna intención de ponerlo en funcionamiento.

En fin lo pondré en conocimiento del cliente a ver q quiere hacer, pero la verdad es q estoy de acuerdo contigo en q no se como hay roots q trabajan así, se me escapa.

Total q tanto trabajo para nada. Pero de todas formas, muchas gracias por todo. Guardaré la info para cuando me vuela a pasar algo parecido (espero q igual igual no).

Muchas gracias de nuevos por molestarte en buscarme la info. Se agradece.

Salu2

Lantrax
__________________
______________________________

LaNTRaX
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 21:29.