Easy way to paste command line output to paste bin services?
There are several services that provide this but 2 that are pretty easy to use from the command line are fpaste
and pastebinit
. These 2 tools link to the sites, paste.fedoraproject.org and pastebin.com.
fpaste
NOTE: This is a Fedora/CentOS/RHEL only option
If you're using any of the Red Hat based distros you can install the package fpaste
which gives you a command line tool for posting content to paste.fedoraproject.org
.
Basic commands
For basic posting of a single text file you can do the following.
$ fpaste hello_unixnlinux.txt
The above command will return a URL where your content can now be accessed by others.
...
Uploading (0.1KiB)...
http://ur1.ca/gddtt -> http://paste.fedoraproject.org/66894/89230131
Other commands
There are of course a whole host of other options.
- paste clipboard:
fpaste -i
- paste sytem info:
fpaste --sysinfo
- dry run: `fpaste --printonly somefile.txt
See the man page, man fpaste
for more details.
pastebinit
This is probably the more popular of the 2 tools. It's supported on most of the distros I frequent such as Fedora, CentOS, and Ubuntu just to name a few. It has similar features to fpaste
but, you can do a whole lot more with it, for example:
list of services
For starters we can get a list of all the "supported" URLs via the -l
switch.
$ pastebinit -l
Supported pastebins:
- cxg.de
- fpaste.org
- p.defau.lt
- paste.debian.net
- paste.drizzle.org
- paste.kde.org
- paste.openstack.org
- paste.pocoo.org
- paste.pound-python.org
- paste.ubuntu.com
- paste.ubuntu.org.cn
- paste2.org
- pastebin.com
- pastie.org
- pb.daviey.com
- slexy.org
- sprunge.us
If you don't bother to select one using the -b
switch, it will pick one based on your distro, assuming there's one for it, otherwise falling back to pastebin.com. Notice it also supports fpaste.org
, for Fedora, so you could use this tool to cover that pasting service as well.
Posting a simple text file
To post a sample file to pastebin.com
.
$ pastebinit -i hello_unixnlinux.txt -b http://pastebin.com
http://pastebin.com/d6uXieZj
Posting code
You can also tell that the content you're pasting is code using the -f
switch. For example here's a Bash script. We're also going to name the upload using the -a
switch, so that it will show up with the name "ex_bash_1".
$ pastebinit -i sample.bash -f bash -a ex_bash_1 -b http://pastebin.com
http://pastebin.com/jGvyysQ9
A full list of syntax's supported, is covered in the pastebin.com FAQ under this topic titled: For which languages do you offer syntax highlighting?.
For further details be cure to check the man pages, man pastebinit
.
Samples
Here are 2 examples of the file that I posted to each service.
fpaste - http://ur1.ca/gddtt
pastebin - http://pastebin.com/jGvyysQ9
References
- COMMAND LINE OUTPUT TO PASTEBIN - PASTEBINIT
I like the two command line tools that use curl
, listed on the Arch Wiki:
<command> | curl -F 'sprunge=<-' http://sprunge.us
<command> 2>&1 | curl -F 'f:1=<-' ix.io
You can make a simple function to save you having to remember the gory details, like so:
sprung() { curl -F "sprunge=<-" http://sprunge.us <"$1" ;}
You can send to an enhanced URL if you would like syntax highlighting for your code paste. For ix, you append either /ID/
to the URL (http://ix.io/ID/) for default syntax based on auto-detection, or /ID/<language>/
to explicitly set the language for pygments highlighting.
For http://sprunge.us, append ?<language>
for the same effect.
I needed something to share terminal output even when X server wasn't loaded so I created this service: termbin.com. The only thing you need is netcat, then you can easily share with anyone anything that can be shown in terminal, there's example:
cat /etc/fstab | nc termbin.com 9999
After running this command you'll get in response url address with text file.
To make your life easier you can add such alias to your .bashrc file:
echo 'alias tb="nc termbin.com 9999"' >> .bashrc
Now sharing will be much simplier:
uname -a | tb
You can get saved ones for example by using curl. You'll find more examples on termbin.com.
You can host your own server as well, there is github repository: https://github.com/solusipse/fiche. If you want to make it private, don't forget to set whitelist parameter.