Created

Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

PASTEBIN.COM BASH SCRIPT – PASTE DIRECTLY FROM YOUR TERMINAL

View pastebin.sh
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
#!/bin/bash
# Paste at Pastebin.com using command line (browsers are slow, right?)
# coder : Anil Dewani
# date : Novemeber 7, 2010
 
#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="paste_private=0&paste_code=${INPUT}&paste_name=${NAME}&paste_email=${EMAIL}&paste_format=${TYPE}"
 
#post data to pastebin.com API
curl -d "${querystring}" http://pastebin.com/api_public.php
 
echo ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.