File: pastebin

package info (click to toggle)
xapp 2.8.13-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,724 kB
  • sloc: ansic: 11,268; python: 1,463; xml: 258; sh: 22; makefile: 9
file content (30 lines) | stat: -rwxr-xr-x 776 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/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 != "":
    if os.path.exists('/usr/bin/fpaste'):
        p = subprocess.Popen(['/usr/bin/fpaste'], stdin=subprocess.PIPE)
        p.communicate(content.encode("UTF-8"))
    else:
        p = subprocess.Popen(['nc', 'termbin.com', '9999'], stdin=subprocess.PIPE)
        p.communicate(content.encode("UTF-8"))