Skip to content

Instantly share code, notes, and snippets.

@igordcard
Forked from yevgenko/pastebin.sh
Last active June 12, 2018 10:50
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 igordcard/9517847 to your computer and use it in GitHub Desktop.
Save igordcard/9517847 to your computer and use it in GitHub Desktop.
Updated to the latest Pastebin.com API.
#!/bin/bash
# Paste at Pastebin.com using command line (browsers are slow, right?)
# coder : Anil Dewani
# date : November 7, 2010
# forker : Igor Duarte Cardoso
# date : March 12, 2014
# Don't forget to set your Unique Developer API Key here
# http://pastebin.com/api#1
API_KEY=
#help function
howto()
{
echo "\
Pastebin.com Bash Script \
Usage : $0 [ -n <paste name> ] [ -e <paste email> ] [ -t <type of code> ] [ -h ]
<paste name> Specify the name of paste to be used (optional)
<paste email> Specify email to be used while pasting (optional)
<type of code> Specify code language used, use any of the following values (optional and default value is plain text)
=> Some famous [ -t <type of code> ] Values::
php - PHP
actionscript3 - Action Script 3
asp - ASP
bash - BASH script
c - C language
csharp - C#
cpp - C++
java - JAVA
sql - SQL
"
}
NAME=
EMAIL=
TYPE=
#getopts, config
while getopts "n:e:t:h" OPTION
do
case $OPTION in
n)
NAME=$OPTARG
;;
e)
EMAIL=$OPTARG
;;
t)
TYPE=$OPTARG
;;
h)
howto
exit
;;
?)
howto
exit
;;
esac
done
#get data from stdin
INPUT="$(</dev/stdin)"
querystring="api_dev_key=${API_KEY}&api_option=paste&api_paste_private=0&api_paste_expire_date=10M&api_paste_code=${INPUT}&api_paste_name=${NAME}&api_paste_email=${EMAIL}&api_paste_format=${TYPE}"
#post data to pastebin.com API
curl -d "${querystring}" http://pastebin.com/api/api_post.php
echo ""
@AlessandroSpallina
Copy link

Thx

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