Skip to content

Instantly share code, notes, and snippets.

@ktmud
Last active October 13, 2025 21:41
Show Gist options
  • Select an option

  • Save ktmud/4351431 to your computer and use it in GitHub Desktop.

Select an option

Save ktmud/4351431 to your computer and use it in GitHub Desktop.

Revisions

  1. ktmud renamed this gist Dec 21, 2012. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. ktmud created this gist Dec 21, 2012.
    71 changes: 71 additions & 0 deletions bastbin.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    #!/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 ""

    # via: http://www.anildewani.com/pastebin-com-bash-script-paste-directly-from-your-terminal/