Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get the file size from http://www.abc.com/file.txt?

Status
Not open for further replies.
This works sometimes. Not all servers deliver the doc length as part of their header. Maybe, the servers you are dealing with will.

Code:
#!/usr/local/bin/perl
use LWP::Simple;
$url = '[URL unfurl="true"]http://www.someserver.com';[/URL]
($content_type,$doc_length,$modified,$expires,$server) = head($url);
print "For $url, doc length is $doc_length.\n";


An alternative might be to retreive the page and look at it..... this takes a little longer, but, may do the trick.
Code:
#!/usr/local/bin/perl
use LWP::Simple;
$url = '[URL unfurl="true"]http://www.someserver.com';[/URL]
getstore($url,"junk.html");

$size = (stat('junk.html'))[7];
print "size - $size\n";
unlink './junk.html';

HTH





keep the rudder amid ship and beware the odd typo
 
I just wanted to say thanks. This was a lot of help.
right on

Keep Boating
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top