Announcement

Collapse
No announcement yet.

How to: Post a file to Ubuntu pastebin in text mode

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to: Post a file to Ubuntu pastebin in text mode

    When helping others solve problems, it's often handy to look at files of various types -- configurations, logs, etc. Sometimes copying and pasting files into replies here can be difficult, especially if the X windowing system isn't working or if the files are particularly long. Fortuntely, the Ubuntu repository contains a handy utility called pastebinit that reads a file, posts it to Ubuntu's pastebin, and returns the URL.

    Install the utility:
    Code:
    sudo apt-get install pastebinit
    To send a file to the pastebin, run the utility with the name of the file. For example:
    Code:
    pastebinit /var/log/syslog
    If you need to send a file that only the root user can read, don't forget to use sudo. For example:
    Code:
    sudo pastebinit /var/log/fsck/checkroot
    When you run pastebinit, the utility will output to the console the URL of the file. If you're using the tool to create a file you'd like someone on the forum to read, include that URL in your message.

    Now here's a neat trick. Say you need to post several files, all in one subdirectory. You can a short command script for that. For example:
    Code:
    for i in /var/log/lightdm/*; do echo -n "$i - "; sudo pastebinit $i; done
    The command above reads each file in /var/log/lightdm, displays the name of the file on the screen, posts the file to the pastebin, and returns the URL. (I've used the LightDM logs in my example, thus the need for sudo.) Now, rather than copying the contents of each file into a message here, you can just copy and paste the brief output from running the script. Forum readers will see the file name and the neighboring URL and can view the contents of each file.

    When pasting the output, don't enclose it in CODE tags. That way, the forum will interpret the URL as a real URL and allow it to be clicked. I'll run the above command on my own computer so you can see what I mean. (The numbers are made up; the files aren't actually from my PC.)

    /var/log/lightdm/lightdm.log - http://paste.ubuntu.com/00000001/
    /var/log/lightdm/x-0-greeter.log - http://paste.ubuntu.com/00000002/
    /var/log/lightdm/x-0-greeter.log.old - http://paste.ubuntu.com/00000003/
    /var/log/lightdm/x-0.log - http://paste.ubuntu.com/00000004/

    Very handy.
    Last edited by SteveRiley; Feb 02, 2013, 03:22 AM.

    #2
    Pastebinit is sweet...

    Comment


      #3
      Ok, now write a ServiceMenu for it!

      Please Read Me

      Comment

      Working...
      X