Skip to content

Instantly share code, notes, and snippets.

@djmitche
Created July 27, 2011 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save djmitche/1110510 to your computer and use it in GitHub Desktop.
Save djmitche/1110510 to your computer and use it in GitHub Desktop.
stdin-to-pastebin script by @catlee
#!/usr/bin/python
import urllib, sys
if len(sys.argv) == 2:
url = "http://%s.pastebin.mozilla.org" % sys.argv[1]
fmt = sys.argv[1]
else:
url = "http://pastebin.mozilla.org"
fmt = "None"
body = sys.stdin.read()
params = [
('parent_pid', ''),
('code2', body),
('poster', ''),
('expiry', 'd'),
('paste', 'Send'),
('format', fmt),
]
data = urllib.urlencode(params)
req = urllib.urlopen(url, data)
print req.geturl()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment