Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- #pastebin script
- if test -e ~/.pb_api_key; then
- API_KEY=`cat ~/.pb_api_key`
- else
- echo "API Key not set! Place your API key into ~/.pb_api_key."
- exit
- fi
- if test -e ~/.pb_login_key; then
- LOGIN_KEY=`cat ~/.pb_login_key`
- fi
- if test "$1" = "--help" -o "$1" = "help"; then
- if test "$2" = "format"; then
- echo "Formats:"
- echo " - 4cs: 4CS"
- echo " - 6502acme: 6502 ACME Cross Assembler"
- echo " - 6502kickass: 6502 Kick Assembler"
- echo " - 6502tasm: 6502 TASM/64TASS"
- echo " - abap: ABAP"
- echo " - actionscript: ActionScript"
- echo " - actionscript3: ActionScript 3"
- echo " - ada: Ada"
- echo " - aimms: AIMMS"
- echo " - algol68: ALGOL 68"
- echo " - apache: Apache Log"
- echo " - applescript: AppleScript"
- echo " - apt_sources: APT Sources"
- echo " - arduino: Arduino"
- echo " - arm: ARM"
- echo " - asm: ASM (NASM)"
- echo " - asp: ASP"
- echo " - asymptote: Asymptote"
- echo " - autoconf: autoconf"
- echo " - autohotkey: Autohotkey"
- echo " - autoit: AutoIt"
- echo " - avisynth: Avisynth"
- echo " - awk: Awk"
- echo " - bascomavr: BASCOM AVR"
- echo " - bash: Bash"
- echo " - basic4gl: Basic4GL"
- echo " - dos: Batch"
- echo " - bibtex: BibTeX"
- echo " - blitzbasic: Blitz Basic"
- echo " - b3d: Blitz3D"
- echo " - bmx: BlitzMax"
- echo " - bnf: BNF"
- echo " - boo: BOO"
- echo " - bf: BrainFuck"
- echo " - c: C"
- echo " - c_winapi: C (WinAPI)"
- echo " - c_mac: C for Macs"
- echo " - cil: C Intermediate Language"
- echo " - csharp: C#"
- echo " - cpp: C++"
- echo " - cpp-winapi: C++ (WinAPI)"
- echo " - cpp-qt: C++ (with Qt extension)"
- echo " - c_loadrunner: C: Loadrunner"
- echo " - caddcl: CAD DCL"
- echo " - cadlisp: CAD Lisp"
- echo " - ceylon: Ceylon"
- echo " - cfdg: CFDG"
- echo " - chaiscript: ChaiScript"
- echo " - chapel: Chapel"
- echo " - clojure: Clojure"
- echo " - klonec: Clone C"
- echo " - klonecpp: Clone C++"
- echo " - cmake: CMake"
- echo " - cobol: COBOL"
- echo " - coffeescript: CoffeeScript"
- echo " - cfm: ColdFusion"
- echo " - css: CSS"
- echo " - cuesheet: Cuesheet"
- echo " - d: D"
- echo " - dart: Dart"
- echo " - dcl: DCL"
- echo " - dcpu16: DCPU-16"
- echo " - dcs: DCS"
- echo " - delphi: Delphi"
- echo " - oxygene: Delphi Prism (Oxygene)"
- echo " - diff: Diff"
- echo " - div: DIV"
- echo " - dot: DOT"
- echo " - e: E"
- echo " - ezt: Easytrieve"
- echo " - ecmascript: ECMAScript"
- echo " - eiffel: Eiffel"
- echo " - email: Email"
- echo " - epc: EPC"
- echo " - erlang: Erlang"
- echo " - euphoria: Euphoria"
- echo " - fsharp: F#"
- echo " - falcon: Falcon"
- echo " - filemaker: Filemaker"
- echo " - fo: FO Language"
- echo " - f1: Formula One"
- echo " - fortran: Fortran"
- echo " - freebasic: FreeBasic"
- echo " - freeswitch: FreeSWITCH"
- echo " - gambas: GAMBAS"
- echo " - gml: Game Maker"
- echo " - gdb: GDB"
- echo " - genero: Genero"
- echo " - genie: Genie"
- echo " - gettext: GetText"
- echo " - go: Go"
- echo " - groovy: Groovy"
- echo " - gwbasic: GwBasic"
- echo " - haskell: Haskell"
- echo " - haxe: Haxe"
- echo " - hicest: HicEst"
- echo " - hq9plus: HQ9 Plus"
- echo " - html4strict: HTML"
- echo " - html5: HTML 5"
- echo " - icon: Icon"
- echo " - idl: IDL"
- echo " - ini: INI file"
- echo " - inno: Inno Script"
- echo " - intercal: INTERCAL"
- echo " - io: IO"
- echo " - ispfpanel: ISPF Panel Definition"
- echo " - j: J"
- echo " - java: Java"
- echo " - java5: Java 5"
- echo " - javascript: JavaScript"
- echo " - jcl: JCL"
- echo " - jquery: jQuery"
- echo " - json: JSON"
- echo " - julia: Julia"
- echo " - kixtart: KiXtart"
- echo " - kotlin: Kotlin"
- echo " - latex: Latex"
- echo " - ldif: LDIF"
- echo " - lb: Liberty BASIC"
- echo " - lsl2: Linden Scripting"
- echo " - lisp: Lisp"
- echo " - llvm: LLVM"
- echo " - locobasic: Loco Basic"
- echo " - logtalk: Logtalk"
- echo " - lolcode: LOL Code"
- echo " - lotusformulas: Lotus Formulas"
- echo " - lotusscript: Lotus Script"
- echo " - lscript: LScript"
- echo " - lua: Lua"
- echo " - m68k: M68000 Assembler"
- echo " - magiksf: MagikSF"
- echo " - make: Make"
- echo " - mapbasic: MapBasic"
- echo " - markdown: Markdown"
- echo " - matlab: MatLab"
- echo " - mirc: mIRC"
- echo " - mmix: MIX Assembler"
- echo " - modula2: Modula 2"
- echo " - modula3: Modula 3"
- echo " - 68000devpac: Motorola 68000 HiSoft Dev"
- echo " - mpasm: MPASM"
- echo " - mxml: MXML"
- echo " - mysql: MySQL"
- echo " - nagios: Nagios"
- echo " - netrexx: NetRexx"
- echo " - newlisp: newLISP"
- echo " - nginx: Nginx"
- echo " - nim: Nim"
- echo " - text: None"
- echo " - nsis: NullSoft Installer"
- echo " - oberon2: Oberon 2"
- echo " - objeck: Objeck Programming Language"
- echo " - objc: Objective C"
- echo " - ocaml: OCaml"
- echo " - ocaml-brief: OCaml Brief"
- echo " - octave: Octave"
- echo " - oorexx: Open Object Rexx"
- echo " - pf: OpenBSD PACKET FILTER"
- echo " - glsl: OpenGL Shading"
- echo " - oobas: Openoffice BASIC"
- echo " - oracle11: Oracle 11"
- echo " - oracle8: Oracle 8"
- echo " - oz: Oz"
- echo " - parasail: ParaSail"
- echo " - parigp: PARI/GP"
- echo " - pascal: Pascal"
- echo " - pawn: Pawn"
- echo " - pcre: PCRE"
- echo " - per: Per"
- echo " - perl: Perl"
- echo " - perl6: Perl 6"
- echo " - php: PHP"
- echo " - php-brief: PHP Brief"
- echo " - pic16: Pic 16"
- echo " - pike: Pike"
- echo " - pixelbender: Pixel Bender"
- echo " - pli: PL/I"
- echo " - plsql: PL/SQL"
- echo " - postgresql: PostgreSQL"
- echo " - postscript: PostScript"
- echo " - povray: POV-Ray"
- echo " - powerbuilder: PowerBuilder"
- echo " - powershell: PowerShell"
- echo " - proftpd: ProFTPd"
- echo " - progress: Progress"
- echo " - prolog: Prolog"
- echo " - properties: Properties"
- echo " - providex: ProvideX"
- echo " - puppet: Puppet"
- echo " - purebasic: PureBasic"
- echo " - pycon: PyCon"
- echo " - python: Python"
- echo " - pys60: Python for S60"
- echo " - q: q/kdb+"
- echo " - qbasic: QBasic"
- echo " - qml: QML"
- echo " - rsplus: R"
- echo " - racket: Racket"
- echo " - rails: Rails"
- echo " - rbs: RBScript"
- echo " - rebol: REBOL"
- echo " - reg: REG"
- echo " - rexx: Rexx"
- echo " - robots: Robots"
- echo " - rpmspec: RPM Spec"
- echo " - ruby: Ruby"
- echo " - gnuplot: Ruby Gnuplot"
- echo " - rust: Rust"
- echo " - sas: SAS"
- echo " - scala: Scala"
- echo " - scheme: Scheme"
- echo " - scilab: Scilab"
- echo " - scl: SCL"
- echo " - sdlbasic: SdlBasic"
- echo " - smalltalk: Smalltalk"
- echo " - smarty: Smarty"
- echo " - spark: SPARK"
- echo " - sparql: SPARQL"
- echo " - sqf: SQF"
- echo " - sql: SQL"
- echo " - standardml: StandardML"
- echo " - stonescript: StoneScript"
- echo " - sclang: SuperCollider"
- echo " - swift: Swift"
- echo " - systemverilog: SystemVerilog"
- echo " - tsql: T-SQL"
- echo " - tcl: TCL"
- echo " - teraterm: Tera Term"
- echo " - thinbasic: thinBasic"
- echo " - typoscript: TypoScript"
- echo " - unicon: Unicon"
- echo " - uscript: UnrealScript"
- echo " - upc: UPC"
- echo " - urbi: Urbi"
- echo " - vala: Vala"
- echo " - vbnet: VB.NET"
- echo " - vbscript: VBScript"
- echo " - vedit: Vedit"
- echo " - verilog: VeriLog"
- echo " - vhdl: VHDL"
- echo " - vim: VIM"
- echo " - visualprolog: Visual Pro Log"
- echo " - vb: VisualBasic"
- echo " - visualfoxpro: VisualFoxPro"
- echo " - whitespace: WhiteSpace"
- echo " - whois: WHOIS"
- echo " - winbatch: Winbatch"
- echo " - xbasic: XBasic"
- echo " - xml: XML"
- echo " - xorg_conf: Xorg Config"
- echo " - xpp: XPP"
- echo " - yaml: YAML"
- echo " - z80: Z80 Assembler"
- echo " - zxbasic: ZXBasic"
- else
- echo "Commands:"
- echo " - help: show this screen"
- echo " - login: log into pastebin with '$0 login username password'"
- echo " - paste: Paste something with '$0 paste pastedata [name] [format] [expire] [privacy] [asguest]' e.g. '$0 paste some_code Code z80 2W public Y'."
- echo " - pastefile: Paste some file with '$0 pastefile filename [name] [format] [expire] [privacy] [asguest]' e.g. '$0 pastefile ~/test.c Code c 2W public Y'."
- echo "Expiries:"
- echo " - N: Never"
- echo " - 10M: 10 Minutes"
- echo " - 1H: 1 Hour"
- echo " - 1D: 1 Day"
- echo " - 1W: 1 Week"
- echo " - 2W: 2 Weeks"
- echo " - 1M: 1 Month"
- echo " - 6M: 6 Months"
- echo " - 1Y: 1 Year"
- echo "Privacies:"
- echo " - public"
- echo " - unlisted"
- echo " - private"
- echo "For formats, use '$0 help format'"
- fi
- elif test "$1" = "login"; then
- curl --data-urlencode "api_dev_key=$API_KEY" --data-urlencode "api_user_name=$2" --data-urlencode "api_user_password=$3" "https://pastebin.com/api/api_login.php" >~/.pb_temp_login_key
- if grep -i '^Bad' ~/.pb_temp_login_key; then
- echo "Error logging in: " `cat ~/.pb_temp_login_key`
- rm ~/.pb_temp_login_key
- elif test -s ~/.pb_temp_login_key; then
- echo "Logging in appears to be successful!"
- mv ~/.pb_temp_login_key ~/.pb_login_key
- else
- echo "Login process interrupted. Do you have internet?"
- fi
- elif test "$1" = "paste"; then
- #'$0 paste pastedata [name] [format] [expire] [privacy] [asguest]' e.g. '$0 paste some_code Code z80 2W public Y'."
- if test -z "$2"; then
- echo "No paste data specified!"
- exit
- fi
- if test ! -z "$3"; then
- PB_NAME="api_paste_name=$3"
- fi
- if test ! -z "$4"; then
- PB_FORMAT="api_paste_format=$4"
- else
- PB_FORMAT="api_paste_format=text"
- fi
- if test ! -z "$5"; then
- if test "$5" = "10M" -o "$5" = "1H" -o "$5" = "1D" -o "$5" = "1W" -o "$5" = "2W" -o "$5" = "1M" -o "$5" = "6M" -o "$5" = "1Y"; then
- PB_EXPIRE="api_paste_expire_date=$5"
- else
- echo "Invalid expiry time '$5'!"
- exit
- fi
- else
- PB_EXPIRE="api_paste_expire_date=N"
- fi
- if test "$6" = "public" -o -z "$6"; then
- PB_PRIVACY="api_paste_private=0"
- elif test "$6" = "unlisted"; then
- PB_PRIVACY="api_paste_private=1"
- elif test "$6" = "private"; then
- PB_PRIVACY="api_paste_private=2"
- else
- echo "Unknown privacy level '$6'!"
- exit
- fi
- if test -z "$7" -o "$7" = "N"; then
- PB_USER="api_user_key=$LOGIN_KEY"
- fi
- curl --data-urlencode "api_dev_key=$API_KEY" --data-urlencode "api_option=paste" --data-urlencode "api_paste_code=$2" --data-urlencode "$PB_NAME" --data-urlencode "$PB_FORMAT" --data-urlencode "$PB_EXPIRE" --data-urlencode "$PB_PRIVACY" --data-urlencode "$PB_USER" "https://pastebin.com/api/api_post.php" >~/.pb_temp_response
- if grep -i '^Bad' ~/.pb_temp_response; then
- echo "Error sending paste data: " `cat ~/.pb_temp_response`
- rm ~/.pb_temp_response
- elif test -s ~/.pb_temp_response; then
- echo "Pasting appears to be successful!"
- echo "Your paste is at: " `cat ~/.pb_temp_response`
- mv ~/.pb_temp_response ~/.pb_last_url
- else
- echo "Paste process interrupted. Do you have internet?"
- fi
- elif test "$1" = "pastefile"; then
- #'$0 pastefile filename [name] [format] [expire] [privacy] [asguest]' e.g. '$0 paste ~/test.c Code c 2W public Y'."
- if test ! -z "$2"; then
- PASTE_FILE=`cat $2`
- PB_DATA="api_paste_code=$PASTE_FILE"
- else
- echo "No paste file specified!"
- exit
- fi
- if test ! -z "$3"; then
- PB_NAME="api_paste_name=$3"
- fi
- if test ! -z "$4"; then
- PB_FORMAT="api_paste_format=$4"
- else
- PB_FORMAT="api_paste_format=text"
- fi
- if test ! -z "$5"; then
- if test "$5" = "10M" -o "$5" = "1H" -o "$5" = "1D" -o "$5" = "1W" -o "$5" = "2W" -o "$5" = "1M" -o "$5" = "6M" -o "$5" = "1Y"; then
- PB_EXPIRE="api_paste_expire_date=$5"
- else
- echo "Invalid expiry time '$5'!"
- exit
- fi
- else
- PB_EXPIRE="api_paste_expire_date=N"
- fi
- if test "$6" = "public" -o -z "$6"; then
- PB_PRIVACY="api_paste_private=0"
- elif test "$6" = "unlisted"; then
- PB_PRIVACY="api_paste_private=1"
- elif test "$6" = "private"; then
- PB_PRIVACY="api_paste_private=2"
- else
- echo "Unknown privacy level '$6'!"
- exit
- fi
- if test -z "$7" -o "$7" = "N"; then
- PB_USER="api_user_key=$LOGIN_KEY"
- fi
- curl --data-urlencode "api_dev_key=$API_KEY" --data-urlencode "api_option=paste" --data-urlencode "$PB_DATA" --data-urlencode "$PB_NAME" --data-urlencode "$PB_FORMAT" --data-urlencode "$PB_EXPIRE" --data-urlencode "$PB_PRIVACY" --data-urlencode "$PB_USER" "https://pastebin.com/api/api_post.php" >~/.pb_temp_response
- if grep -i '^Bad' ~/.pb_temp_response; then
- echo "Error sending paste data: " `cat ~/.pb_temp_response`
- rm ~/.pb_temp_response
- elif test -s ~/.pb_temp_response; then
- echo "Pasting appears to be successful!"
- echo "Your paste is at: " `cat ~/.pb_temp_response`
- mv ~/.pb_temp_response ~/.pb_last_url
- else
- echo "Paste process interrupted. Do you have internet?"
- fi
- else
- echo "Unknown command '$1' - use '$0 help' for help."
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement