Monday, October 18, 2010

bikeshed: pbput and pbget (pastebin binary files)

I absolutely love the pastebinit tool, from Stephane Graber. Genius, I tell you. I must use it 20 times per day, to share source code and configuration files.

Sometimes, I need to share a binary file, such as a screen shot, or a tarball.

For that, I wrote the pbput (and pbget) scripts!

The pbput script works on either standard in, or a file argument, lzma compresses the input, base64 encodes it, and then uses pastebinit to post to pastebin.com.

And the pbget script basically reverses that process, using wget to retrieve the remote data, base64 decoding it, lzma decompressing it, and writing it to standard out.

Try it for yourself!
  pbput /tmp/Screenshot.png
http://pastebin.com/c9JtQ4WT

pbget http://pastebin.com/c9JtQ4WT > /tmp/out.png
md5sum /tmp/*png
f7e7ba26a2681c0666ebca022c504594 /tmp/out.png
f7e7ba26a2681c0666ebca022c504594 /tmp/Screenshot.png
If you find this useful, install the bikeshed package from Natty, or from the Bikeshed PPA for other versions of Ubuntu.

:-Dustin

6 comments:

  1. I love pastebinit as well. My only gripe is that it uses pastebin.com by default. I prefer paste.ubuntu.com as it's much cleaner.

    I've filed a bug for it, so hopefully Stephane will take it into consideration (https://bugs.edge.launchpad.net/ubuntu/+source/pastebinit/+bug/648298).

    ReplyDelete
  2. This is really cool! However, I was really hoping for an easter egg.

    ReplyDelete
  3. Sweet!
    How are you dealing with size-limited pastebins ?
    If I remember well, a lot of them don't let you post something longer than x hundreds of lines.

    ReplyDelete
  4. stgraber-

    It only supports pastebin.com right now, which has a ~1MB limit. I could make that configurable, I suppose.

    BTW, would you be interested in taking this (or implementing this concept) in pastebinit? My scripts are shell, and pastebinit is python, which is the only reason I haven't sent it to you yet...

    :-Dustin

    ReplyDelete
  5. Brian,

    Here you go:
    * http://pastebin.com/dkW2Z0xK

    :-Dustin

    ReplyDelete
  6. Hey Mario,

    Yeah, I agree. I have had this in my .bashrc for the last few years:

    alias pastebinit='pastebinit -b http://paste.ubuntu.com'

    Unfortunately, I can't use paste.ubuntu.com for pbput/pbget because the raw download is behind an openid auth.

    :-Dustin

    ReplyDelete

Please do not use blog comments for support requests! Blog comments do not scale well to this effect.

Instead, please use Launchpad for Bugs and StackExchange for Questions.
* bugs.launchpad.net
* stackexchange.com

Thanks,
:-Dustin