Skip to content

Instantly share code, notes, and snippets.

@jonguenther
Forked from ktmud/pastebin.sh
Last active February 15, 2022 03:46
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonguenther/e43977be33827ed45bc5b32a394cdf65 to your computer and use it in GitHub Desktop.
Save jonguenther/e43977be33827ed45bc5b32a394cdf65 to your computer and use it in GitHub Desktop.
Bash Script to upload files and data to Pastebin.com
#!/bin/sh
# Paste at Pastebin.com using command line (browsers are slow, right?)
# coder : Anil Dewani
# date : Novemeber 7, 2010
# revised on June 22, 2018 by Jonathan Guenther
# see README for more information (if I have time to create one...)
echo +--------------------------------------------+
echo "|USAGE: ./pastebin.sh content title[optional]|"
echo +--------------------------------------------+
# Your Data
NAME="${2}" # title of your bin
INPUT="${1}" # content of your bin
EMAIL= # deprecated (...?)
TYPE= # set File type (e.g. text, php, js; for more go to https://pastebin.com/api#5 )
USER_KEY= # your userkey
DEV_KEY= # your devkey
# for more options see the pastebin.com API ( https://pastebin.com/api )
# combine to query
QUERY="api_paste_private=0&api_paste_code=${INPUT}&api_paste_name=${NAME}&paste_email=${EMAIL}&api_paste_format=${TYPE}&api_option=paste"
# post data to pastebin.com API
curl -d "${QUERY}" https://pastebin.com/api/api_post.php
# the command will return the pastebin.com link to the newly created bin if successful
# if unsuccessful, it will return the errorcode provided by pastebin.com
# Note: If you just want to upload code / text to copy&paste between two machines quick and dirty, I suggest you use termbin.com
# Just type `echo your text goes here or maybe some file or whatever you want | nc https://termbin.com 9999`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment