vc não pode usar Net::FTP com o metodo size para decidir se vc vai pegar o arquivo ou não?<br><br><div class="gmail_quote">2013/3/8 Nicole Scherer <span dir="ltr"><<a href="mailto:bionica2007-perl@yahoo.com" target="_blank">bionica2007-perl@yahoo.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:12pt;font-family:times new roman,new york,times,serif"><span>Oi Mongers,<br><br>venho humildemente consultar o vasto conhecimento de vocês em prol da pesquisa científica.<br>
<br>Preciso consultar o tamanho de um arquivo em um servidor ftp, antes de decidir se o arquivo deverá ou não ser baixado.<br>Eu estava usando o LWP::Simple::head($url) para isto, e estava funcionando bem, até eu ter que usá-lo através de um proxy.<br>
O que acontece é o seguinte, usando sem proxy, eu consigo acessar as informações sobre tamanho, formato, codificação, etc,<br><br><br>my $downloadfile = "<a href="ftp://hgdownload.cse.ucsc.edu/goldenPath/ce4/database/all_est.txt.gz" target="_blank">ftp://hgdownload.cse.ucsc.edu/goldenPath/ce4/database/all_est.txt.gz</a>";<br>
</span><span>my ($content_type, $document_length, $modified_time, $expires, $server) = LWP::Simple::head($downloadfile);<br><br>--- ou<br><br></span><span>if (my $res =
LWP::Simple::head($downloadfile)) {<br> print "$downloadfile ok\n"; ### debug<br> p($res->{_headers});<br>} else {<br> print "$downloadfile not available\n"; ### debug<br>}<br><br><br>--- e quando uso <br>
<br>use LWP::Simple qw($ua head);<br>$ua->proxy([qw(http ftp wais)], 'http://10.46.10.19:3129');<br><br></span><div>para definir o proxy, ele não retorna estas informações.</div><div><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">Se eu mandar imprimir $res->{_headers}, tenho isso:</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">--- rodando sem proxy</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">HTTP::Headers {<br> public methods (38) : as_string, authorization, authorization_basic, clear, client_date, content_encoding, content_is_html, content_is_text, content_is_xhtml, content_is_xml, content_language, content_length, content_type, content_type_charset, date, expires, from, header, header_field_names, if_modified_since, if_unmodified_since, init_header, last_modified, new,
proxy_authenticate, proxy_authorization, proxy_authorization_basic, push_header, referer, referrer, remove_content_headers, remove_header, scan, server, title, user_agent, warning, www_authenticate<br> private methods (5) : _basic_auth, _date_header, _header, _process_newline, _sorted_field_names<br>
internals: {<br> client-date => "Fri, 08 Mar 2013 19:33:58 GMT",<br> client-request-num => 1,<br> content-encoding => "gzip",<br> content-length => 14169205,<br>
content-type =>
"text/plain",<br> last-modified => "Mon, 14 Mar 2011 16:52:05 GMT",<br> server => "FTP Server"<br> }<br>}<br><br></div><br><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">--- com proxy</div>HTTP::Headers {<br> public methods (38) : as_string, authorization, authorization_basic, clear, client_date, content_encoding, content_is_html, content_is_text, content_is_xhtml, content_is_xml, content_language, content_length, content_type,
content_type_charset, date, expires, from, header, header_field_names, if_modified_since, if_unmodified_since, init_header, last_modified, new, proxy_authenticate, proxy_authorization, proxy_authorization_basic, push_header, referer, referrer, remove_content_headers, remove_header, scan, server, title, user_agent, warning, www_authenticate<br>
private methods (5) : _basic_auth, _date_header, _header, _process_newline, _sorted_field_names<br> internals: {<br> client-date => "Fri, 08 Mar 2013 19:36:13 GMT",<br> client-peer => "<a href="http://10.46.10.19:3129" target="_blank">10.46.10.19:3129</a>",<br>
client-response-num => 1,<br>
connection => "close",<br> date => "Fri, 08 Mar 2013 19:35:52 GMT"<br> }<br>}<br><br><br><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">Ele simplesmente não cria/recebe content-encoding, content-length, content-type, last-modified e server. </div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">Só o que eu preciso mesmo é o
content-length.</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
By the way, o LWP::UserAgent head() não me informa o tamanho do arquivo. Pelo menos não nos meus testes.</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">Vocês conhecem alguma outra maneira de obter a informação de tamanho do arquivo sem ter que baixá-lo?</div>
<div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">Acessando o directory listing também não dá, porque através do proxy, o formato que ele retorna varia em cada sistema (pelo menos foi o que eu observei. me corrijam se eu estiver errada).<br>
</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">Obrigada!</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">Abraços,</div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
Nicole<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif">
<br></div><div style="font-style:normal;font-size:16px;background-color:transparent;font-family:times new roman,new york,times,serif"><br></div></div></div><br>_______________________________________________<br>
Rio-pm mailing list<br>
<a href="mailto:Rio-pm@pm.org">Rio-pm@pm.org</a><br>
<a href="http://mail.pm.org/mailman/listinfo/rio-pm" target="_blank">http://mail.pm.org/mailman/listinfo/rio-pm</a><br></blockquote></div><br><br clear="all"><div><br></div>-- <br>Tiago B. Peczenyj<br>Linux User #405772<br>
<br><a href="http://about.me/peczenyj" target="_blank">http://about.me/peczenyj</a>