Skip to content

Instantly share code, notes, and snippets.

@k0s
Forked from djmitche/pbmoz.py
Created July 28, 2011 16:08
Show Gist options
  • Save k0s/1111831 to your computer and use it in GitHub Desktop.
Save k0s/1111831 to your computer and use it in GitHub Desktop.
stdin-to-pastebin script by @catlee
#!/usr/bin/env 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()
@k0s
Copy link
Author

k0s commented Jul 28, 2011

shebang should be #!/usr/bin/env python

@modeswitch
Copy link

Actuallly, it should be #!/usr/bin/env python2 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment