Newsgrupos.com  

Retroceder   Newsgrupos.com > Forum > Newsgroup es.comp.lenguajes.* Foro > Newsgroup es.comp.lenguajes.misc
Registrarse Preguntas Frecuentes Lista de Foreros Calendario Buscar Temas de Hoy Marcar Foros Como Leídos




Respuesta
 
LinkBack Herramientas Desplegado
  #1 (permalink)  
Antiguo 10-06-2005, 02:51:29
master.soccer@gmail.com
 
Mensajes: n/a
Predeterminado Invocar HTML desde CGI

Hola:

Alguien sabe como es posible llamar desde un CGI una página Web y
luego analizar el resultado para desplegar un mensaje de OK o FALLO,
según el resultado obtenido como salida del HTML.

Thanks

Master Soccer

Responder Con Cita
Alt Today
Advertising
Google Adsense
 
This advertising will not be shown
in this way to registered members.
Register your free account today
and become a member on
Newsgrupos.com
Standard Sponsored Links

  #2 (permalink)  
Antiguo 10-06-2005, 04:47:37
Pascal Bourguignon
 
Mensajes: n/a
Predeterminado Re: Invocar HTML desde CGI

master.soccer***gmail.com writes:
> Alguien sabe como es posible llamar desde un CGI una página Web y
> luego analizar el resultado para desplegar un mensaje de OK o FALLO,
> según el resultado obtenido como salida del HTML.


Un CGI es un programa como cualquier otro. Puedes hacer todo lo que
quieras en un programa.

Por ejemplo el siguiente cgi me da, con:

http://localhost/cgi/demo.cgi?q=http...ch%3Fq%3Dparis

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=paris</p>
<p>El resultado es : OK</p>
</body></html>

y con:

http://localhost/cgi/demo.cgi?q=http...h%3Fq%3Dmadrid

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=madrid</p>
<p>El resultado es : FALLO</p>
</body></html>



-----(demo.cgi)---------------------------------------------------------
#!/usr/bin/clisp -q -ansi -norc -K full -E iso-8859-1
;; -*- mode:lisp -*-
(format t "Content-type: text/html~3%")
(finish-output)

(format t "<html><head><title>Resultado</title></head><body>~%")

(DEFUN QUERY-UNESCAPE (QPART)
"
RETURN: A string where the + are replaced by spaces
and the %HL are replaced by the caracter whose code is HL
in hexadecimal.
"
(DO ((RESULT (MAKE-STRING (LENGTH QPART)))
(I 0)
(J 0))
((<= (LENGTH QPART) I) (SUBSEQ RESULT 0 J))
(COND
((CHAR= (CHARACTER "+") (CHAR QPART I))
(SETF (CHAR RESULT J) (CHARACTER " "))
(INCF J)
(INCF I))
((AND (CHAR= (CHARACTER "%") (CHAR QPART I))
(< (+ I 2) (LENGTH QPART)))
(LET ((CODE (PARSE-INTEGER QPART :START (+ I 1) :END (+ I 3) :RADIX 16)))
(COND
((NULL CODE)
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I))
((= 13 CODE)
(INCF I 3))
(T
(SETF (CHAR RESULT J) (CODE-CHAR CODE)) (INCF J) (INCF I 3))) ))
(T
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I)))))

(format t "<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>~%")

(let* ((q (ext:getenv "QUERY_STRING"))
(p (when q (position (character "=") q))))
(when p
(let ((result))
(format t "<p>~A</p>~%" (query-unescape (subseq q (1+ p))))
(with-open-file (out "/tmp/test.html" :direction utput
:if-does-not-exist :create
:if-exists :supersede)
(with-open-stream
(html (ext:run-program "lynx"
:arguments (list "-source"
(query-unescape (subseq q (1+ p))))
utput :stream))
(loop for line = (read-line html nil nil)
while line
do
(format out "~A~%" line)
(when (regexp:match "Paris" line) (return (setf result t))))))
(format t "<p>El resultado es : ~:[FALLO~;OK~]</p>~%" result))))

(format t "</body></html>~%")
(finish-output)
(sleep 1)
(ext:exit 0)
------------------------------------------------------------------------

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
Responder Con Cita
  #3 (permalink)  
Antiguo 10-06-2005, 04:47:37
Pascal Bourguignon
 
Mensajes: n/a
Predeterminado Re: Invocar HTML desde CGI

master.soccer***gmail.com writes:
> Alguien sabe como es posible llamar desde un CGI una página Web y
> luego analizar el resultado para desplegar un mensaje de OK o FALLO,
> según el resultado obtenido como salida del HTML.


Un CGI es un programa como cualquier otro. Puedes hacer todo lo que
quieras en un programa.

Por ejemplo el siguiente cgi me da, con:

http://localhost/cgi/demo.cgi?q=http...ch%3Fq%3Dparis

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=paris</p>
<p>El resultado es : OK</p>
</body></html>

y con:

http://localhost/cgi/demo.cgi?q=http...h%3Fq%3Dmadrid

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=madrid</p>
<p>El resultado es : FALLO</p>
</body></html>



-----(demo.cgi)---------------------------------------------------------
#!/usr/bin/clisp -q -ansi -norc -K full -E iso-8859-1
;; -*- mode:lisp -*-
(format t "Content-type: text/html~3%")
(finish-output)

(format t "<html><head><title>Resultado</title></head><body>~%")

(DEFUN QUERY-UNESCAPE (QPART)
"
RETURN: A string where the + are replaced by spaces
and the %HL are replaced by the caracter whose code is HL
in hexadecimal.
"
(DO ((RESULT (MAKE-STRING (LENGTH QPART)))
(I 0)
(J 0))
((<= (LENGTH QPART) I) (SUBSEQ RESULT 0 J))
(COND
((CHAR= (CHARACTER "+") (CHAR QPART I))
(SETF (CHAR RESULT J) (CHARACTER " "))
(INCF J)
(INCF I))
((AND (CHAR= (CHARACTER "%") (CHAR QPART I))
(< (+ I 2) (LENGTH QPART)))
(LET ((CODE (PARSE-INTEGER QPART :START (+ I 1) :END (+ I 3) :RADIX 16)))
(COND
((NULL CODE)
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I))
((= 13 CODE)
(INCF I 3))
(T
(SETF (CHAR RESULT J) (CODE-CHAR CODE)) (INCF J) (INCF I 3))) ))
(T
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I)))))

(format t "<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>~%")

(let* ((q (ext:getenv "QUERY_STRING"))
(p (when q (position (character "=") q))))
(when p
(let ((result))
(format t "<p>~A</p>~%" (query-unescape (subseq q (1+ p))))
(with-open-file (out "/tmp/test.html" :direction utput
:if-does-not-exist :create
:if-exists :supersede)
(with-open-stream
(html (ext:run-program "lynx"
:arguments (list "-source"
(query-unescape (subseq q (1+ p))))
utput :stream))
(loop for line = (read-line html nil nil)
while line
do
(format out "~A~%" line)
(when (regexp:match "Paris" line) (return (setf result t))))))
(format t "<p>El resultado es : ~:[FALLO~;OK~]</p>~%" result))))

(format t "</body></html>~%")
(finish-output)
(sleep 1)
(ext:exit 0)
------------------------------------------------------------------------

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
Responder Con Cita
  #4 (permalink)  
Antiguo 10-06-2005, 04:47:37
Pascal Bourguignon
 
Mensajes: n/a
Predeterminado Re: Invocar HTML desde CGI

master.soccer***gmail.com writes:
> Alguien sabe como es posible llamar desde un CGI una página Web y
> luego analizar el resultado para desplegar un mensaje de OK o FALLO,
> según el resultado obtenido como salida del HTML.


Un CGI es un programa como cualquier otro. Puedes hacer todo lo que
quieras en un programa.

Por ejemplo el siguiente cgi me da, con:

http://localhost/cgi/demo.cgi?q=http...ch%3Fq%3Dparis

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=paris</p>
<p>El resultado es : OK</p>
</body></html>

y con:

http://localhost/cgi/demo.cgi?q=http...h%3Fq%3Dmadrid

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=madrid</p>
<p>El resultado es : FALLO</p>
</body></html>



-----(demo.cgi)---------------------------------------------------------
#!/usr/bin/clisp -q -ansi -norc -K full -E iso-8859-1
;; -*- mode:lisp -*-
(format t "Content-type: text/html~3%")
(finish-output)

(format t "<html><head><title>Resultado</title></head><body>~%")

(DEFUN QUERY-UNESCAPE (QPART)
"
RETURN: A string where the + are replaced by spaces
and the %HL are replaced by the caracter whose code is HL
in hexadecimal.
"
(DO ((RESULT (MAKE-STRING (LENGTH QPART)))
(I 0)
(J 0))
((<= (LENGTH QPART) I) (SUBSEQ RESULT 0 J))
(COND
((CHAR= (CHARACTER "+") (CHAR QPART I))
(SETF (CHAR RESULT J) (CHARACTER " "))
(INCF J)
(INCF I))
((AND (CHAR= (CHARACTER "%") (CHAR QPART I))
(< (+ I 2) (LENGTH QPART)))
(LET ((CODE (PARSE-INTEGER QPART :START (+ I 1) :END (+ I 3) :RADIX 16)))
(COND
((NULL CODE)
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I))
((= 13 CODE)
(INCF I 3))
(T
(SETF (CHAR RESULT J) (CODE-CHAR CODE)) (INCF J) (INCF I 3))) ))
(T
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I)))))

(format t "<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>~%")

(let* ((q (ext:getenv "QUERY_STRING"))
(p (when q (position (character "=") q))))
(when p
(let ((result))
(format t "<p>~A</p>~%" (query-unescape (subseq q (1+ p))))
(with-open-file (out "/tmp/test.html" :direction utput
:if-does-not-exist :create
:if-exists :supersede)
(with-open-stream
(html (ext:run-program "lynx"
:arguments (list "-source"
(query-unescape (subseq q (1+ p))))
utput :stream))
(loop for line = (read-line html nil nil)
while line
do
(format out "~A~%" line)
(when (regexp:match "Paris" line) (return (setf result t))))))
(format t "<p>El resultado es : ~:[FALLO~;OK~]</p>~%" result))))

(format t "</body></html>~%")
(finish-output)
(sleep 1)
(ext:exit 0)
------------------------------------------------------------------------

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
Responder Con Cita
  #5 (permalink)  
Antiguo 10-06-2005, 04:47:37
Pascal Bourguignon
 
Mensajes: n/a
Predeterminado Re: Invocar HTML desde CGI

master.soccer***gmail.com writes:
> Alguien sabe como es posible llamar desde un CGI una página Web y
> luego analizar el resultado para desplegar un mensaje de OK o FALLO,
> según el resultado obtenido como salida del HTML.


Un CGI es un programa como cualquier otro. Puedes hacer todo lo que
quieras en un programa.

Por ejemplo el siguiente cgi me da, con:

http://localhost/cgi/demo.cgi?q=http...ch%3Fq%3Dparis

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=paris</p>
<p>El resultado es : OK</p>
</body></html>

y con:

http://localhost/cgi/demo.cgi?q=http...h%3Fq%3Dmadrid

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=madrid</p>
<p>El resultado es : FALLO</p>
</body></html>



-----(demo.cgi)---------------------------------------------------------
#!/usr/bin/clisp -q -ansi -norc -K full -E iso-8859-1
;; -*- mode:lisp -*-
(format t "Content-type: text/html~3%")
(finish-output)

(format t "<html><head><title>Resultado</title></head><body>~%")

(DEFUN QUERY-UNESCAPE (QPART)
"
RETURN: A string where the + are replaced by spaces
and the %HL are replaced by the caracter whose code is HL
in hexadecimal.
"
(DO ((RESULT (MAKE-STRING (LENGTH QPART)))
(I 0)
(J 0))
((<= (LENGTH QPART) I) (SUBSEQ RESULT 0 J))
(COND
((CHAR= (CHARACTER "+") (CHAR QPART I))
(SETF (CHAR RESULT J) (CHARACTER " "))
(INCF J)
(INCF I))
((AND (CHAR= (CHARACTER "%") (CHAR QPART I))
(< (+ I 2) (LENGTH QPART)))
(LET ((CODE (PARSE-INTEGER QPART :START (+ I 1) :END (+ I 3) :RADIX 16)))
(COND
((NULL CODE)
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I))
((= 13 CODE)
(INCF I 3))
(T
(SETF (CHAR RESULT J) (CODE-CHAR CODE)) (INCF J) (INCF I 3))) ))
(T
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I)))))

(format t "<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>~%")

(let* ((q (ext:getenv "QUERY_STRING"))
(p (when q (position (character "=") q))))
(when p
(let ((result))
(format t "<p>~A</p>~%" (query-unescape (subseq q (1+ p))))
(with-open-file (out "/tmp/test.html" :direction utput
:if-does-not-exist :create
:if-exists :supersede)
(with-open-stream
(html (ext:run-program "lynx"
:arguments (list "-source"
(query-unescape (subseq q (1+ p))))
utput :stream))
(loop for line = (read-line html nil nil)
while line
do
(format out "~A~%" line)
(when (regexp:match "Paris" line) (return (setf result t))))))
(format t "<p>El resultado es : ~:[FALLO~;OK~]</p>~%" result))))

(format t "</body></html>~%")
(finish-output)
(sleep 1)
(ext:exit 0)
------------------------------------------------------------------------

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
Responder Con Cita
  #6 (permalink)  
Antiguo 10-06-2005, 04:47:37
Pascal Bourguignon
 
Mensajes: n/a
Predeterminado Re: Invocar HTML desde CGI

master.soccer***gmail.com writes:
> Alguien sabe como es posible llamar desde un CGI una página Web y
> luego analizar el resultado para desplegar un mensaje de OK o FALLO,
> según el resultado obtenido como salida del HTML.


Un CGI es un programa como cualquier otro. Puedes hacer todo lo que
quieras en un programa.

Por ejemplo el siguiente cgi me da, con:

http://localhost/cgi/demo.cgi?q=http...ch%3Fq%3Dparis

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=paris</p>
<p>El resultado es : OK</p>
</body></html>

y con:

http://localhost/cgi/demo.cgi?q=http...h%3Fq%3Dmadrid

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=madrid</p>
<p>El resultado es : FALLO</p>
</body></html>



-----(demo.cgi)---------------------------------------------------------
#!/usr/bin/clisp -q -ansi -norc -K full -E iso-8859-1
;; -*- mode:lisp -*-
(format t "Content-type: text/html~3%")
(finish-output)

(format t "<html><head><title>Resultado</title></head><body>~%")

(DEFUN QUERY-UNESCAPE (QPART)
"
RETURN: A string where the + are replaced by spaces
and the %HL are replaced by the caracter whose code is HL
in hexadecimal.
"
(DO ((RESULT (MAKE-STRING (LENGTH QPART)))
(I 0)
(J 0))
((<= (LENGTH QPART) I) (SUBSEQ RESULT 0 J))
(COND
((CHAR= (CHARACTER "+") (CHAR QPART I))
(SETF (CHAR RESULT J) (CHARACTER " "))
(INCF J)
(INCF I))
((AND (CHAR= (CHARACTER "%") (CHAR QPART I))
(< (+ I 2) (LENGTH QPART)))
(LET ((CODE (PARSE-INTEGER QPART :START (+ I 1) :END (+ I 3) :RADIX 16)))
(COND
((NULL CODE)
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I))
((= 13 CODE)
(INCF I 3))
(T
(SETF (CHAR RESULT J) (CODE-CHAR CODE)) (INCF J) (INCF I 3))) ))
(T
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I)))))

(format t "<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>~%")

(let* ((q (ext:getenv "QUERY_STRING"))
(p (when q (position (character "=") q))))
(when p
(let ((result))
(format t "<p>~A</p>~%" (query-unescape (subseq q (1+ p))))
(with-open-file (out "/tmp/test.html" :direction utput
:if-does-not-exist :create
:if-exists :supersede)
(with-open-stream
(html (ext:run-program "lynx"
:arguments (list "-source"
(query-unescape (subseq q (1+ p))))
utput :stream))
(loop for line = (read-line html nil nil)
while line
do
(format out "~A~%" line)
(when (regexp:match "Paris" line) (return (setf result t))))))
(format t "<p>El resultado es : ~:[FALLO~;OK~]</p>~%" result))))

(format t "</body></html>~%")
(finish-output)
(sleep 1)
(ext:exit 0)
------------------------------------------------------------------------

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
Responder Con Cita
  #7 (permalink)  
Antiguo 10-06-2005, 04:47:37
Pascal Bourguignon
 
Mensajes: n/a
Predeterminado Re: Invocar HTML desde CGI

master.soccer***gmail.com writes:
> Alguien sabe como es posible llamar desde un CGI una página Web y
> luego analizar el resultado para desplegar un mensaje de OK o FALLO,
> según el resultado obtenido como salida del HTML.


Un CGI es un programa como cualquier otro. Puedes hacer todo lo que
quieras en un programa.

Por ejemplo el siguiente cgi me da, con:

http://localhost/cgi/demo.cgi?q=http...ch%3Fq%3Dparis

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=paris</p>
<p>El resultado es : OK</p>
</body></html>

y con:

http://localhost/cgi/demo.cgi?q=http...h%3Fq%3Dmadrid

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=madrid</p>
<p>El resultado es : FALLO</p>
</body></html>



-----(demo.cgi)---------------------------------------------------------
#!/usr/bin/clisp -q -ansi -norc -K full -E iso-8859-1
;; -*- mode:lisp -*-
(format t "Content-type: text/html~3%")
(finish-output)

(format t "<html><head><title>Resultado</title></head><body>~%")

(DEFUN QUERY-UNESCAPE (QPART)
"
RETURN: A string where the + are replaced by spaces
and the %HL are replaced by the caracter whose code is HL
in hexadecimal.
"
(DO ((RESULT (MAKE-STRING (LENGTH QPART)))
(I 0)
(J 0))
((<= (LENGTH QPART) I) (SUBSEQ RESULT 0 J))
(COND
((CHAR= (CHARACTER "+") (CHAR QPART I))
(SETF (CHAR RESULT J) (CHARACTER " "))
(INCF J)
(INCF I))
((AND (CHAR= (CHARACTER "%") (CHAR QPART I))
(< (+ I 2) (LENGTH QPART)))
(LET ((CODE (PARSE-INTEGER QPART :START (+ I 1) :END (+ I 3) :RADIX 16)))
(COND
((NULL CODE)
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I))
((= 13 CODE)
(INCF I 3))
(T
(SETF (CHAR RESULT J) (CODE-CHAR CODE)) (INCF J) (INCF I 3))) ))
(T
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I)))))

(format t "<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>~%")

(let* ((q (ext:getenv "QUERY_STRING"))
(p (when q (position (character "=") q))))
(when p
(let ((result))
(format t "<p>~A</p>~%" (query-unescape (subseq q (1+ p))))
(with-open-file (out "/tmp/test.html" :direction utput
:if-does-not-exist :create
:if-exists :supersede)
(with-open-stream
(html (ext:run-program "lynx"
:arguments (list "-source"
(query-unescape (subseq q (1+ p))))
utput :stream))
(loop for line = (read-line html nil nil)
while line
do
(format out "~A~%" line)
(when (regexp:match "Paris" line) (return (setf result t))))))
(format t "<p>El resultado es : ~:[FALLO~;OK~]</p>~%" result))))

(format t "</body></html>~%")
(finish-output)
(sleep 1)
(ext:exit 0)
------------------------------------------------------------------------

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
Responder Con Cita
  #8 (permalink)  
Antiguo 10-06-2005, 04:47:37
Pascal Bourguignon
 
Mensajes: n/a
Predeterminado Re: Invocar HTML desde CGI

master.soccer***gmail.com writes:
> Alguien sabe como es posible llamar desde un CGI una página Web y
> luego analizar el resultado para desplegar un mensaje de OK o FALLO,
> según el resultado obtenido como salida del HTML.


Un CGI es un programa como cualquier otro. Puedes hacer todo lo que
quieras en un programa.

Por ejemplo el siguiente cgi me da, con:

http://localhost/cgi/demo.cgi?q=http...ch%3Fq%3Dparis

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=paris</p>
<p>El resultado es : OK</p>
</body></html>

y con:

http://localhost/cgi/demo.cgi?q=http...h%3Fq%3Dmadrid

<html><head><title>Resultado</title></head><body>
<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>
<p>http://www.google.com/search?q=madrid</p>
<p>El resultado es : FALLO</p>
</body></html>



-----(demo.cgi)---------------------------------------------------------
#!/usr/bin/clisp -q -ansi -norc -K full -E iso-8859-1
;; -*- mode:lisp -*-
(format t "Content-type: text/html~3%")
(finish-output)

(format t "<html><head><title>Resultado</title></head><body>~%")

(DEFUN QUERY-UNESCAPE (QPART)
"
RETURN: A string where the + are replaced by spaces
and the %HL are replaced by the caracter whose code is HL
in hexadecimal.
"
(DO ((RESULT (MAKE-STRING (LENGTH QPART)))
(I 0)
(J 0))
((<= (LENGTH QPART) I) (SUBSEQ RESULT 0 J))
(COND
((CHAR= (CHARACTER "+") (CHAR QPART I))
(SETF (CHAR RESULT J) (CHARACTER " "))
(INCF J)
(INCF I))
((AND (CHAR= (CHARACTER "%") (CHAR QPART I))
(< (+ I 2) (LENGTH QPART)))
(LET ((CODE (PARSE-INTEGER QPART :START (+ I 1) :END (+ I 3) :RADIX 16)))
(COND
((NULL CODE)
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I))
((= 13 CODE)
(INCF I 3))
(T
(SETF (CHAR RESULT J) (CODE-CHAR CODE)) (INCF J) (INCF I 3))) ))
(T
(SETF (CHAR RESULT J) (CHAR QPART I)) (INCF J) (INCF I)))))

(format t "<form method=GET action=demo.cgi>
<p>URL: </p><input type=text name=q size=100></input>
</form>~%")

(let* ((q (ext:getenv "QUERY_STRING"))
(p (when q (position (character "=") q))))
(when p
(let ((result))
(format t "<p>~A</p>~%" (query-unescape (subseq q (1+ p))))
(with-open-file (out "/tmp/test.html" :direction utput
:if-does-not-exist :create
:if-exists :supersede)
(with-open-stream
(html (ext:run-program "lynx"
:arguments (list "-source"
(query-unescape (subseq q (1+ p))))
utput :stream))
(loop for line = (read-line html nil nil)
while line
do
(format out "~A~%" line)
(when (regexp:match "Paris" line) (return (setf result t))))))
(format t "<p>El resultado es : ~:[FALLO~;OK~]</p>~%" result))))

(format t "</body></html>~%")
(finish-output)
(sleep 1)
(ext:exit 0)
------------------------------------------------------------------------

--
__Pascal Bourguignon__ http://www.informatimago.com/

There is no worse tyranny than to force a man to pay for what he does not
want merely because you think it would be good for him. -- Robert Heinlein
Responder Con Cita
 
Respuesta


Herramientas
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Trackbacks are habilitado
Pingbacks are habilitado
Refbacks are habilitado


Temas Similares
Tema Autor Foro Respuestas Último mensaje
Invocar reporte desde un WebServices o ASPX Carlos Hidalgo Newsgroup microsoft.public.es.dotnet.aspnet 5 11-01-2008 13:21:22
Es posible invocar un ASP desde un tag IMG??? Manuel Vera Newsgroup microsoft.public.es.asp 0 18-05-2007 19:09:48
Invocar una página desde la IP del equipo FGF Newsgroup microsoft.public.es.vc 0 12-12-2006 11:48:14
Invocar Submit desde Java Script Oswaldo Newsgroup microsoft.public.es.java 0 03-03-2006 19:07:28
Invocar página web desde CGI master.soccer@gmail.com Newsgroup es.comp.lenguajes.c 6 10-06-2005 07:23:50





Powered by: vBulletin, Versión 3.6.8
Derechos de Autor ©2000 - 2008, Jelsoft Enterprises Ltd.

LinkBacks Enabled by vBSEO 3.1.0 © 2007, Crawlability, Inc.