AYUDA (fwd)
Juan Godinez
jgodinez@dgenp.unam.mx
Sun, 27 Sep 1998 01:17:29 -0600
Hola Lista Perl
No se que tanto pueda ayudar el siguiente consejo a resolver tu problema,
cuando capturas un texto en plataforma DOS y lo llevas a UNIX siempre
te va a cambiar los ENTER por ^M (ctrl M) y creanlo o no, solo por ese
caracter no funcionaba mi CGI, no le afecta a todas las lineas, pero por mala
suerte a veces afecta a las lineas importantes, te sugiero que lo edites en
"vi" y borres los ctrl M que encuentres al final de tus lineas, no es necesario
que borres todos ya que por lo que veo son muchas lineas, pero tienes que estar
haciendo pruebas para ver si funciona.
Espero te sirva de al este comentario.
Aprovechando, me pueden decir si puedo tener en una sola PC WIN95, LINUX y
NETWARE;
y elegir en que sistema deseo arrancar.
Gracias
Juan
At 09:11 PM 15/09/98 -0600, you wrote:
>Content-Type: TEXT/HTML; CHARSET=iso-8859-1
>Content-ID: <Pine.SOL.3.91.980915211016.12028C@campus>
>
>Hola:
>
>Les env'io este mensaje que me lleg'o a mi direcci'on personal.
>
>Saludos,
>
> Roberto Andrade Fonseca
> Universidad Nacional Autonoma de Mexico
>
> Phone: 623-1154, 623-1345
> e-mail: randrade@campus.iztacala.unam.mx
>
>---------- Forwarded message ----------
>Date: Tue, 15 Sep 1998 22:52:51 +0200
>From: LA =?iso-8859-1?Q?P=C1GINA?= DEL ROTTWEILER <info@rottweiler.drago.net>
>To: randrade@campus.iztacala.unam.mx
>Subject: AYUDA
>
><html>
>HOLA <br>
>PERDONA QUE TE MOLESTE PERO ES QUE NECESITO QUE ALGUIEN ME AYUDE PORQUE
>ESTOY DESESPERADO. <br>
>RESULTA QUE TENGO UN CGI PARA HACER UN BUSCADOR Y APENAS HAY QUE TOCAR
>NADA, UNICAMENTE LA PRIMERA FRASE, QUE EN VEZ DE PONER
>#!/usr/local/bin/perl HAY QUE QUITAR LA PALABRA local. QUE ES DONDE MI
>SERVIDOR TIENE EL INTÉRPRETE <br>
>ESTO LO HE HECHO CON EL WORDPAD COMO ME HAN DICHO. LO HE MANDADO A MI
>SERVIDOR EN MODO ASCII, COMO ME HAN DICHO Y ELLOS LO HAN PUESTO
>EJECUTABLE Y NO SE QUE MAS. PUES RESULTA QUE NO FUNCIONA Y ME DICEN QUE
>EL CGI TIENE UN FALLO O NO LO MANDO BIEN POR
><font color="#0000FF"><u>FTP</font></u><font color="#000000">. <br>
>A MI ME CONSTA QUE NO TIENE NINGÚN FALLO PUESTO QUE NO HE TOCADO NADA Y
>ADEMÁS EL AMIGO QUE ME LO HA PASADO LE FUNCIONA ESTUPENDAMENTE, LO TIENE
>EN
></font><font color="#0000FF"><u>http://<a href="http://www.inchi.com yo lo
tengo en http:/" eudora="autourl">www.inchi.com</a></font></u><font
color="#000000">
><br>
>YO LO TENGO EN
></font><a href="http://www.inchi.com yo lo tengo en http:/"
eudora="autourl"><font color="#0000FF"><u>http:</a>//<a
href="http://www.dragonet.es/"
eudora="autourl">www.dragonet.es</a>/users/picolo/pruebaA.htm</font></u><fon
t color="#000000">
>POR SI QUIERES VER EL MENSAJE DE ERROR QUE SALE, Y TE MANDO TAMBIÉN LOS
>ARCHIVOS POR SI QUIERES AYUDARME Y ECHARLE UN OJILLO. TE ESTARÉ
>ETERNAMENTE AGRADECIDO. <br>
>UN SALUDO Y ESPERO TU RESPUESTA. <br>
>JOSE<br>
></font></html>
>Content-Type: TEXT/HTML; CHARSET=us-ascii
>Content-ID: <Pine.SOL.3.91.980915211016.12028D@campus>
>
><HTML>
><HEAD><TITLE>URL Search Engines</Title></HEAD>
>
><BODY background="../backc2.gif" BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF
VLINK=#800040 ALINK=#800040>
>
>
>
><TABLE WIDTH=100% Border=0 Cellpadding=7 Cellspacing=0 >
><TR>
><TD Width=155 valign=top align=left>
><A HREF="http://www.technotrade.com"><IMG SRC="../stechno3.gif"
Alt="Techno Trade Logo" border=0></A><BR>
> &nb
sp; &
nbsp;
></TD>
><TD valign=top >
><CENTER><FONT SIZE=5 COLOR=800000 FACE="ARIAL,TIMES NEW ROMAN">URL Search
Engine</FONT></CENTER>
><BR>
><CENTER>
><A HREF="http://www.promoteone.com/techno">
><IMG SRC="http://www.technotrade.com/cgi/promote.gif" width=400 Height=60
ALT="Get listed towards the top of major search engines" border=1></A><BR>
><FONT SIZE=-1><A HREF="http://www.promoteone.com/techno">Visit Our
Sponsor</A></FONT>
></CENTER>
>
><BR><BR>
></TD>
></TR>
>
>
><TR>
><TD valign=top align=center>
><FONT SIZE=3 COLOR=A50000 FACE="ARIAL,TIMES NEW ROMAN">Description</FONT>
></TD>
><TD>
>
>Feel like starting your own little yahoo ? Well, this is basically what
this script does. It searches a Text database file for one or more keywords
input by the user and displays all the URLs that match the Search Query.
This can also be changed to search any type of text database file.
>
><TR>
><TD valign=top align=center>
><FONT SIZE=3 COLOR=A50000 FACE="ARIAL,TIMES NEW ROMAN">How it Works</FONT>
></TD>
><TD>
>
>There are three main files needed for the script to run properly.<BR>
><OL>
><LI><B>urlsrch.cgi</B> : This is the cgi script the does both searching and
adding of new records so be sure to chmod it to 755 (executable).
><LI><B>urls.txt</B> : This is where all the data is stored and where new
records are added so chmod it to 666 which gives write permissions to the file.
><LI><B>urlsrch.html</B> : This is the html file that functions for both
searching and adding records so be sure not to change any of the FORM values
in it.
></OL>
>
><TR>
><TD valign=top align=center>
><FONT SIZE=3 COLOR=A50000 FACE="ARIAL,TIMES NEW ROMAN">Sample<BR>urls.txt
file</FONT>
></TD>
><TD>
><TABLE Width=100% Border=1 Cellpadding=3 Cellspacing=0>
><TR>
><TD>
>Page Title | What My Page is about | Keyword1 | my email |
http://mypage.com<BR>
>Rent-A-Car | car rental reservations | rentals | e-mail |
http://www.carrental.com<BR>
></TD>
></TR>
></TABLE>
>Format : <FONT SIZE=3 COLOR=004080>Title | Description | Keywords | e-mail
| URL</FONT>
><BR><BR>
>Each line makes up one record and each record is made up of fields
separated by a pipe "|" character.
><BR><BR>
><BR>
><TR>
><TD valign=top align=center>
><FONT SIZE=3 COLOR=A50000 FACE="ARIAL,TIMES NEW
ROMAN">Download<BR>and<BR>Demo</FONT>
></TD>
><TD>
>
><CENTER>
><A HREF="urlsrch.html"><IMG SRC="demos.gif" border=0></A>
><BR><BR>
><A HREF="http://technotrade.com/cgi/urlsrch.txt"><IMG SRC="downs.gif"
border=0></A><BR>
>
><BR>
>
><TABLE Border=1 Width=50% Cellpadding=5 Cellspacing=0>
><TR>
><TD>Price</TD>
><TD align=right>Free</TD>
></TR>
></TABLE>
><BR>
></CENTER>
>
>This script can be modified for custom applications, and it doesn't just
have to be URL search engine. It can also be used for searching virtually
any type of text database... recipes, phone numbers, car dealers etc. The
version that is available here is for a URL search engine, but if you're
insterested in a custom script for your web site then <A
HREF="http://technotrade.com/mail.html"> E-mail </A> me and I can quote you
accordingly.
><BR><BR>
>
><BR>
>
><CENTER>
><BR><A HREF="index.html"><IMG SRC="cgimini.gif" border=0></A>
></CENTER>
></TD>
></TR>
></TABLE>
></BODY>
></HTML>
>Content-Type: TEXT/PLAIN; CHARSET=us-ascii
>Content-ID: <Pine.SOL.3.91.980915211016.12028E@campus>
>
>#!/usr/bin/perl
>####################################################################
># URL Search Engine
># Copyright 1996 Techno Trade http://www.technotrade.com
># Written By : Sammy Afifi sammy@technotrade.com
># Date Last Modified : Jan 14, 1997
>####################################################################
>#
># This script is free of charge.
># Please link back to http://technotrade.com, thank you :-)
>#######
>#
># Jan 14, stops people from entering html tags, converts < to <
>#
>####################################################################
>
># $linktitle, $linkdescrip, $linkwords, $linkemail, $linkurl
># define some global variables
>
> $fields = 5; # Number of fields in each record
> $filename = "urls.txt"; # The database text file
> $results = 1000; # maximum number of results to display
>
> &parse_form;
>
> $searchstring = $FORM{'searchstring'};
>
> &addrecord if ($searchstring eq "**ADD RECORD**");
>
>
> &open_file("FILE1","",$filename);
>
> print "Content-type: text/html\n\n";
> print "<HTML>\n";
> print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF VLINK=#800040
ALINK=#800040>\n";
> print "<TITLE>Search Results</TITLE>\n";
> print "<CENTER><BR>\n";
> print "<FONT SIZE=5 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">Search
Results</FONT></CENTER>\n";
>
> print "<HR width=80% noshade><BR><UL>\n";
> $counter = 0;
>
> while (($line = &read_file("FILE1")) && ($counter < $results)) {
> # split the fields at the | character
> @tabledata = split(/\s*\|\s*/,$line ,$fields);
> &check_record;
> if ($found == 1) {
> $counter++;
> &print_record;
> }
>
> }
> close(FILE1);
> print "</UL>\n";
>
> if ($counter == 0) {
> print "<BR><B> Sorry, No Matches were found.</B>\n";
> }
>
>
> print "<CENTER>\n";
> print "<HR width=80% noshade>\n";
> print "<FONT SIZE=3 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">URL
Search Brought to you by : <A HREF=\"http://www.technotrade.com/cgi\">Techno
Trade's CGI Archive</A></FONT></CENTER>\n";
> print "</CENTER>\n";
> print "</A></BODY></HTML>\n";
>
>
>
>#########################################
>#
># Print the matched record
>#
>#########################################
>sub print_record {
> print "<BR>\n";
> print "<LI><A HREF=" . $linkurl . ">" . $linktitle . "</A> :
$linkdescrip</B><BR>\n";
>}
>
>
>##########################################
>#
># Check to see if record matches search criteria
>#
>##########################################
>sub check_record {
> # get the data from the record read from the file. $tabledata
>
> $linktitle = $tabledata[0];
> $linkdescrip = $tabledata[1];
> $linkwords = $tabledata[2];
> $linemail = $tabledata[3];
> $linkurl = $tabledata[4];
> chop($linkurl);
>
> #build the search line with all fields we want to search in
> $searchline = $linktitle . " " . $linkdescrip . " " . $linkwords;
>
>
> #search by keywords
> # only perform the keyword search if the length of the search string is
greater than 2
> # don't think we want people to search for and or or etc.
> $sfound = 0;
> $found = 0;
> $notfound = 1;
>
> $stlen = length($searchstring);
> if ($stlen > 1) {
> @words = split(/ +/,$searchstring);
> foreach $aword (@words) {
> if ($searchline =~ /\b$aword/i) {
> $sfound = 1;
> }
> else {
> $notfound = 0;
> }
> }
> }
> if ($sfound == 1 && $notfound == 1) {
> $found = 1;
> }
>
> # if search string is too small .. set found to 1
> if ($stlen <= 1) {
> $found = 1;
> }
> #if page doesn't have a title then return not found
> $tlen = length($linktitle);
> if ($tlen < 1) {
> $found = 0;
> }
>}
>
>
>############################################
>#
># Add Record
>#
>############################################
>
>sub addrecord {
>
> $linktitle = $FORM{'linktitle'};
> $linkdescrip = $FORM{'linkdescrip'};
> $linkwords = $FORM{'linkwords'};
> $linkemail = $FORM{'linkemail'};
> $linkurl = $FORM{'linkurl'};
>
> # Convert < tags to <
> $linktitle =~ s/</\</g;
> $linkdescrip =~ s/</\</g;
> $linkwords =~ s/</\</g;
> $linkemail =~ s/</\</g;
> $linkurl =~ s/</\</g;
>
>
>
> &open_file("FILE1",">>",$filename);
>
> &write_file("FILE1",$linktitle . "|". $linkdescrip. "|" .$linkwords ."|"
.$linkemail ."|" .$linkurl ."\n");
> close(FILE1);
> print "Content-type: text/html\n\n";
> print "<html><head><title>Thank You</title></head>\n";
> print "<body><BR><h3><CENTER>Thank You For Adding to this
database</CENTER></h3>\n";
> print "</body></html>\n";
> exit;
>}
>
>
>
>
>
>
>
>
>
>
>
>sub parse_form {
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> if (length($buffer) < 5) {
> $buffer = $ENV{QUERY_STRING};
> }
>
> @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;
> }
>}
>
>
>
>sub open_file {
>
> local ($filevar, $filemode, $filename) = @_;
>
> open ($filevar,$filemode . $filename) ||
> die ("Can't open $filename");
>}
>
>sub read_file {
>
> local ($filevar) = @_;
>
> <$filevar>;
>}
>
>sub write_file {
>
> local ($filevar, $line) = @_;
>
> print $filevar ($line);
>}
>Content-Type: TEXT/PLAIN; CHARSET=us-ascii
>Content-ID: <Pine.SOL.3.91.980915211016.12028F@campus>
>
>#!/usr/bin/perl
>####################################################################
># URL Search Engine
># Copyright 1996 Techno Trade http://www.technotrade.com
># Written By : Sammy Afifi sammy@technotrade.com
># Date Last Modified : Jan 14, 1997
>####################################################################
>#
># This script is free of charge.
># Please link back to http://technotrade.com, thank you :-)
>#######
>#
># Jan 14, stops people from entering html tags, converts < to <
>#
>####################################################################
>
># $linktitle, $linkdescrip, $linkwords, $linkemail, $linkurl
># define some global variables
>
> $fields = 5; # Number of fields in each record
> $filename = "urls.txt"; # The database text file
> $results = 1000; # maximum number of results to display
>
> &parse_form;
>
> $searchstring = $FORM{'searchstring'};
>
> &addrecord if ($searchstring eq "**ADD RECORD**");
>
>
> &open_file("FILE1","",$filename);
>
> print "Content-type: text/html\n\n";
> print "<HTML>\n";
> print "<BODY BGCOLOR=#FFFFFF TEXT=#000000 LINK=#0000FF VLINK=#800040
ALINK=#800040>\n";
> print "<TITLE>Search Results</TITLE>\n";
> print "<CENTER><BR>\n";
> print "<FONT SIZE=5 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">Search
Results</FONT></CENTER>\n";
>
> print "<HR width=80% noshade><BR><UL>\n";
> $counter = 0;
>
> while (($line = &read_file("FILE1")) && ($counter < $results)) {
> # split the fields at the | character
> @tabledata = split(/\s*\|\s*/,$line ,$fields);
> &check_record;
> if ($found == 1) {
> $counter++;
> &print_record;
> }
>
> }
> close(FILE1);
> print "</UL>\n";
>
> if ($counter == 0) {
> print "<BR><B> Sorry, No Matches were found.</B>\n";
> }
>
>
> print "<CENTER>\n";
> print "<HR width=80% noshade>\n";
> print "<FONT SIZE=3 COLOR=000000 FACE=\"ARIAL,TIMES NEW ROMAN\">URL
Search Brought to you by : <A HREF=\"http://www.technotrade.com/cgi\">Techno
Trade's CGI Archive</A></FONT></CENTER>\n";
> print "</CENTER>\n";
> print "</A></BODY></HTML>\n";
>
>
>
>#########################################
>#
># Print the matched record
>#
>#########################################
>sub print_record {
> print "<BR>\n";
> print "<LI><A HREF=" . $linkurl . ">" . $linktitle . "</A> :
$linkdescrip</B><BR>\n";
>}
>
>
>##########################################
>#
># Check to see if record matches search criteria
>#
>##########################################
>sub check_record {
> # get the data from the record read from the file. $tabledata
>
> $linktitle = $tabledata[0];
> $linkdescrip = $tabledata[1];
> $linkwords = $tabledata[2];
> $linemail = $tabledata[3];
> $linkurl = $tabledata[4];
> chop($linkurl);
>
> #build the search line with all fields we want to search in
> $searchline = $linktitle . " " . $linkdescrip . " " . $linkwords;
>
>
> #search by keywords
> # only perform the keyword search if the length of the search string is
greater than 2
> # don't think we want people to search for and or or etc.
> $sfound = 0;
> $found = 0;
> $notfound = 1;
>
> $stlen = length($searchstring);
> if ($stlen > 1) {
> @words = split(/ +/,$searchstring);
> foreach $aword (@words) {
> if ($searchline =~ /\b$aword/i) {
> $sfound = 1;
> }
> else {
> $notfound = 0;
> }
> }
> }
> if ($sfound == 1 && $notfound == 1) {
> $found = 1;
> }
>
> # if search string is too small .. set found to 1
> if ($stlen <= 1) {
> $found = 1;
> }
> #if page doesn't have a title then return not found
> $tlen = length($linktitle);
> if ($tlen < 1) {
> $found = 0;
> }
>}
>
>
>############################################
>#
># Add Record
>#
>############################################
>
>sub addrecord {
>
> $linktitle = $FORM{'linktitle'};
> $linkdescrip = $FORM{'linkdescrip'};
> $linkwords = $FORM{'linkwords'};
> $linkemail = $FORM{'linkemail'};
> $linkurl = $FORM{'linkurl'};
>
> # Convert < tags to <
> $linktitle =~ s/</\</g;
> $linkdescrip =~ s/</\</g;
> $linkwords =~ s/</\</g;
> $linkemail =~ s/</\</g;
> $linkurl =~ s/</\</g;
>
>
>
> &open_file("FILE1",">>",$filename);
>
> &write_file("FILE1",$linktitle . "|". $linkdescrip. "|" .$linkwords ."|"
.$linkemail ."|" .$linkurl ."\n");
> close(FILE1);
> print "Content-type: text/html\n\n";
> print "<html><head><title>Thank You</title></head>\n";
> print "<body><BR><h3><CENTER>Thank You For Adding to this
database</CENTER></h3>\n";
> print "</body></html>\n";
> exit;
>}
>
>
>
>
>
>
>
>
>
>
>
>sub parse_form {
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> if (length($buffer) < 5) {
> $buffer = $ENV{QUERY_STRING};
> }
>
> @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;
> }
>}
>
>
>
>sub open_file {
>
> local ($filevar, $filemode, $filename) = @_;
>
> open ($filevar,$filemode . $filename) ||
> die ("Can't open $filename");
>}
>
>sub read_file {
>
> local ($filevar) = @_;
>
> <$filevar>;
>}
>
>sub write_file {
>
> local ($filevar, $line) = @_;
>
> print $filevar ($line);
>}
>Content-Type: TEXT/HTML; CHARSET=iso-8859-1
>Content-ID: <Pine.SOL.3.91.980915211016.12028G@campus>
>
><html><BR>
>
><div align="center">
><!----------------------------------------------------------------------
----><br>
><!-- <font size=4 color="#FF0000"><b><i>LA PÁGINA DEL
>ROTTWEILER</font></b></i><font size=3 color="#000000"> --><br>
><!-- <b>E-mail:</b>
></font><font color="#0000FF"><b><i>info@rottweiler.drago.net</b></i>
></font><font color="#000000"> --><br>
><!--
><a href="http://www.dragonet.es/users/picolo/rot.htm"
eudora="autourl"><b>http://www.lanzadera.com/ROTTWEILER</a>
></b>--><br>
><!-- <b>José Antonio Jara López </b>
>--><br>
><!-- <b>Email:</b>
></font><font color="#0000FF"><b><i>picolo@dragonet.es</font></b></i><font
color="#000000">
>--><br>
><!----------------------------------------------------------------------
----><br>
></font></html>
>
--------- Pie de mensaje --------------------------------
Visite: http://tlali.iztacala.unam.mx/~randrade/perl.shtml
Cancelar inscripcion:
mail to: majordomo@tlali.iztacala.unam.mx
text : cancelacion perl