Last active
September 27, 2017 01:40
-
-
Save zcot/8418bc736d3f8e401ce610fc812827ab to your computer and use it in GitHub Desktop.
/usr/bin/pastebin-vs-/usr/local/bin/pastebin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import sys | |
import os | |
import stat | |
import subprocess | |
content = "" | |
mode = os.fstat(0).st_mode | |
if stat.S_ISFIFO(mode): | |
content = sys.stdin.read() | |
elif stat.S_ISREG(mode): | |
content = sys.stdin.read() | |
else: | |
args = sys.argv[1:] | |
if len(args) == 1 and os.path.exists(args[0]): | |
with open(args[0], 'r') as infile: | |
content = infile.read() | |
else: | |
str_args = ' '.join(args) | |
content = str_args | |
if content != "": | |
p = subprocess.Popen(["/usr/bin/gist-paste"], stdin=subprocess.PIPE) | |
p.communicate(content.encode("UTF-8")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment