• Jueves 28 de Marzo de 2024, 21:59

Autor Tema:  Problemas Con Lwp::useragent  (Leído 3245 veces)

borix69

  • Nuevo Miembro
  • *
  • Mensajes: 3
    • Ver Perfil
Problemas Con Lwp::useragent
« en: Lunes 6 de Febrero de 2006, 10:39 »
0
Hola a tod@s,

Estoy encontrando problemas con mi script de perl cuando intento descargar algún fichero desde un servidor HTTPS externo.

Mi entorno es el siguiente:

- Sistema operativo: Suse Linux Enterprise Server 8
- Perl 5.8.0-58
- Libwww-perl 5.65-41
- Crypt-SSLeay 0.51
- Cron 3.0.1-649

Mi script de perl es tiene entre otras cosas:

/********************************************/
my $ua = LWP::UserAgent->new;

$ua->timeout(20);
# $ua->env_proxy;

$nombrefichero = shift(@ARGV);
my @URLS = ('https://midominio/' . $nombrefichero);

my $response = $ua->get($laurl);
/********************************************/

El caso es que cuando ejecuto el script desde la consola del linux, el fichero se descarga sin ningún problema generando la siguiente traza:

/********************************************/
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://midominio/mifichero
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
SSL_connect:before/connect initialization
SSL_connect:SSLv3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server key exchange A
SSL_connect:SSLv3 read server done A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL_connect:SSLv3 read finished A
SSL_connect:SSL renegotiate ciphers
SSL_connect:SSLv3 write client hello A
SSL_connect:SSLv3 read server hello A
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server key exchange A
SSL_connect:SSLv3 read server certificate request A
SSL_connect:SSLv3 read server done A
SSL_connect:SSLv3 write client certificate A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write certificate verify A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL_connect:SSLv3 read finished A
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 1000 bytes
LWP::UserAgent::request: Simple response: OK
/********************************************/

Pero si intento automatizar la tarea de descargar el fichero con el cron, cuando este lo ejecuta, obtengo la siguiente traza de error:

/********************************************/
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://midominio/mifichero
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: Internal Server Error
/********************************************/

y el fichero no se descarga.

¿ Alguien tiene alguna idea ?, ¿ pueden ser las variables de entorno ?.

Muchas gracias.

borix69

  • Nuevo Miembro
  • *
  • Mensajes: 3
    • Ver Perfil
Re: Problemas Con Lwp::useragent
« Respuesta #1 en: Lunes 6 de Febrero de 2006, 13:31 »
0
He visto que el proceso falla cuando lo automatizo con el cron o cuando lo ejecuto desde consola directamente con un usuario distinto de root, obteniendo:

LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET https://midominio/mifichero
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::UserAgent::request: Simple response: Internal Server Error

Alguna idea ?

su -

  • Moderador
  • ******
  • Mensajes: 2349
    • Ver Perfil
Re: Problemas Con Lwp::useragent
« Respuesta #2 en: Lunes 6 de Febrero de 2006, 21:44 »
0
Hola.
Yo lo hago asi:
Código: Text
  1. #!/usr/bin/perl -w
  2. use strict;
  3. use LWP::UserAgent;
  4. my ($link, $salida) = @ARGV;
  5. my $ua = LWP::UserAgent->new();
  6. $ua->agent("SoloCodigoBrowser/v0.1");#Por carino
  7. my $return = $ua->get($link);
  8. if($return->is_error()){
  9.   die "Error con $link: $response->status_line";
  10. }
  11. else {
  12.  #....
  13. }
  14.  
  15.  
Espero que te sirva.
 :hola:
*******PELIGRO LEE ESTO!!*******

There is no place like 127.0.0.1

Conecto luego existo, no conecto luego insisto.

su -

  • Moderador
  • ******
  • Mensajes: 2349
    • Ver Perfil
Re: Problemas Con Lwp::useragent
« Respuesta #3 en: Lunes 6 de Febrero de 2006, 22:03 »
0
Ha, si, tienes que hacer un:
open FL, "+>$salida" or die "Error: $!";
print FL $return;
close FL;
 :whistling:
*******PELIGRO LEE ESTO!!*******

There is no place like 127.0.0.1

Conecto luego existo, no conecto luego insisto.

borix69

  • Nuevo Miembro
  • *
  • Mensajes: 3
    • Ver Perfil
Re: Problemas Con Lwp::useragent
« Respuesta #4 en: Martes 7 de Febrero de 2006, 08:57 »
0
Gracias por tus comentarios su !!!

Mi problema al final era otro, resulta muy curioso pero salvo con el usuario root, con todos los demás y con la automatización no me cogía las rutas relativas de los certificados. Al ponerle las rutas absolutas a las variables de entorno:

$ENV{HTTPS_CA_FILE}
$ENV{HTTPS_PKCS12_FILE}
$ENV{HTTPS_PKCS12_PASSWORD}

ya funcionó.

Un saludo y gracias.

su -

  • Moderador
  • ******
  • Mensajes: 2349
    • Ver Perfil
Re: Problemas Con Lwp::useragent
« Respuesta #5 en: Martes 7 de Febrero de 2006, 23:30 »
0
:think:  OK, curioso.
 :hola:
*******PELIGRO LEE ESTO!!*******

There is no place like 127.0.0.1

Conecto luego existo, no conecto luego insisto.