• Publicidad

Problema con envio de PDF por FTP

¿Apenas comienzas con Perl? En este foro podrás encontrar y hacer preguntas básicas de Perl con respuestas aptas a tu nivel.

Problema con envio de PDF por FTP

Notapor coltx » 2016-04-28 12:00 @541

Estimados, tengo el siguiente script para transferir PDF desde un sitio a otro, pero cuando me llegan al otro sitio, llega el PDF en blanco o bien con parte del PDF. Le he dado vueltas al tema y no sé qué puede ser. Desde ya, muchas gracias por su ayuda. Mi script es el siguiente:

Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1. #!/usr/bin/perl
  2.  
  3.  
  4.     use Net::FTP;
  5.     use Net::FTP::File;
  6.  
  7.  
  8.     my $ftp_site     = 'ftp.sitio.com';
  9.     my $port         = '21';
  10.     my $ftp_dir      = 'PDF';
  11.     my $ftp_user     = 'usuario';
  12.     my $ftp_password = 'password';
  13.     my $dir;
  14.     my $file;
  15.     my $dirOUT;
  16.  
  17.     my $ftp = Net::FTP->new($ftp_site, Debug => 0, Port => $port, Passive => 1, Binary => 1);
  18.     $ftp->login($ftp_user, $ftp_password);
  19.     $ftp->cwd($ftp_dir);
  20.  
  21.     $dir="/home/mario/PDF/IN/";
  22.     $dirOUT="/home/mario/PDF/OUT/";
  23.  
  24.         opendir(DIR, $dir);
  25.         foreach $file (readdir(DIR))
  26.         {
  27.  
  28.                 if(($file ne ".") && ($file ne ".."))
  29.                 {
  30.  
  31.                  $ftp->put("$dir/$file",$file);
  32.                  system("mv $dir/$file $dirOUT/$file");
  33.                  print "Transfer file : $file\n";
  34.                 }
  35.  
  36.  
  37.         }
  38.  
  39.         $ftp->quit();
Coloreado en 0.004 segundos, usando GeSHi 1.0.8.4
Última edición por explorer el 2016-04-28 16:28 @728, editado 1 vez en total
Razón: Poner marcasde código Perl
coltx
Perlero nuevo
Perlero nuevo
 
Mensajes: 79
Registrado: 2011-09-16 08:01 @376

Publicidad

Re: Problema con envio de PDF por FTP

Notapor explorer » 2016-04-28 16:57 @748

Te falta activar el modo binario, para la transmisión.

Una línea así:
Sintáxis: [ Descargar ] [ Ocultar ]
Using perl Syntax Highlighting
  1.     $ftp->binary();
Coloreado en 0.001 segundos, usando GeSHi 1.0.8.4
JF^D Perl programming & Raku programming. Grupo en Telegram: https://t.me/Perl_ES
Avatar de Usuario
explorer
Administrador
Administrador
 
Mensajes: 14476
Registrado: 2005-07-24 18:12 @800
Ubicación: Valladolid, España


Volver a Básico

¿Quién está conectado?

Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 3 invitados

cron