Skip to content

Instantly share code, notes, and snippets.

@scottjacksonx
Created March 18, 2010 16:29
Show Gist options
  • Save scottjacksonx/336535 to your computer and use it in GitHub Desktop.
Save scottjacksonx/336535 to your computer and use it in GitHub Desktop.
# I have this on my server so that I can find out the size of any remote file just by SSHing into my server and running this script.
import urllib2
import sys
url = sys.argv[1]
usock = urllib2.urlopen(url)
size = usock.info().get('Content-Length')
if size is None:
size = 0
size = float(size) / 1024.0 / 1024.0 # in bytes
print str(size) + " MBytes"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment