add some doc to sprunge
[xo.git] / sprunge
blobd5711317b251515307f22b44f458f067a3c478ca
1 #!/usr/bin/python
2 # v0.2 31d1@31d1.com
4 # sprunge.us text to url service:
5 # For the Purpose of Making Easier,
6 # the communal debugging of Failed Scripts,
7 # and What Not.
8 #
9 # Install with wget:
10 # wget http://sprunge.us/sprunge
12 # Put the script somewhere in $PATH, pipe text in,
13 # and get a URL where it ended up.
14 # URL should be good for at least 24 hours.
16 # Example:
17 # >$ ls -l | sprunge
18 # http://sprunge.us/1rjub6yu
20 import os.path
21 import sys
22 import urllib
23 import urllib2
25 inp = sys.stdin
26 if inp.isatty():
27 print 'use: <command> | ' + os.path.basename(sys.argv[0])
28 sys.exit()
29 else:
30 inp = inp.read()
32 data = urllib.urlencode({ 'sprunge' : inp })
33 request = urllib2.Request('http://sprunge.us/', data)
34 response = urllib2.urlopen(request)
35 print response.read()