From Gentoo Wiki
Jump to:navigation Jump to:search

wgetpaste is a command-line tool for posting snippets of text to various online "pastebin" services. It makes it easy to post text to a pastebin, and presents a link for sharing the post. It should be very useful for providing information to help with troubleshooting, for posting to IRC or to the forums, for example.

See the service selection section for a list of available pastebin services. Visit a service's website for usage-information specific to that service.

The default service, bpaste, is well suited for posting to Gentoo IRC or requesting support. Services that require javascript to view the posts can be impractical.

Remember that paste services are often public, avoid posting sensitive information. It may not be possible to delete posted information.
See also
See the support article about how to ask for help with Gentoo.


USE flags

wgetpaste currently has just one use flag, for using SSL/TLS or not:

USE flags for app-text/wgetpaste Command-line interface to various pastebins

ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)


Install app-text/wgetpaste:

root #emerge --ask app-text/wgetpaste


Settings, notably the default service, can be configured globally in /etc/wgetpaste.conf or in /etc/wgetpaste.d/*.conf, or per-user in ~/.wgetpaste.conf or in ~/.wgetpaste.d/*.conf.

FILE ~/.wgetpaste.d/main.conf
# Always pass pastes through app-text/ansifilter

# Give raw links which can immediately be used for patches, etc

# Optionally default to gists
# Default gists to secret
# Provide github gist authorization token
HEADER_gists="Authorization: token XXXX"

There is also an example configuration file available from upstream.

Github gists

PUBLIC_gists must be explicitly set to true or false only or it will report an error!

The gists service requires a valid API token. Generate it on the Github website and paste it into a config snippet:

FILE ~/.wgetpaste.d/gists.conf
HEADER_gists="Authorization: token abcdef..."

A gist must be set to public or private by setting the PUBLIC_gists variable either in the config file, or on the command-line, thus (for Bash):

user $PUBLIC_gists=false wgetpaste -s gists <path-to-file>



Invoke wgetpaste with the --help option for useful information on usage:

user $wgetpaste --help
Usage: /usr/bin/wgetpaste [options] [file[s]]

    -l, --language LANG           set language (defaults to "Plain Text")
    -d, --description DESCRIPTION set description (defaults to "stdin" or filename)
    -n, --nick NICK               set nick (defaults to your username)
    -s, --service SERVICE         set service to use (defaults to "dpaste")
    -e, --expiration EXPIRATION   set when it should expire (defaults to "1")

    -S, --list-services           list supported pastebin services
    -L, --list-languages          list languages supported by the specified service
    -E, --list-expiration         list expiration setting supported by the specified service

    -u, --tinyurl URL             convert input url to tinyurl

    -c, --command COMMAND         paste COMMAND and the output of COMMAND
    -i, --info                    append the output of `emerge --info`
    -I, --info-only               paste the output of `emerge --info` only
    -x, --xcut                    read input from clipboard (requires x11-misc/xclip)
    -X, --xpaste                  write resulting url to the X primary selection buffer (requires x11-misc/xclip)
    -C, --xclippaste              write resulting url to the X clipboard selection buffer (requires x11-misc/xclip)

    -r, --raw                     show url for the raw paste (no syntax highlighting or html)
    -t, --tee                     use tee to show what is being pasted
    -v, --verbose                 show wget stderr output if no url is received
        --completions             emit output suitable for shell completions (only affects --list-*)
        --debug                   be *very* verbose (implies -v)

    -h, --help                    show this help
    -g, --ignore-configs          ignore ""/etc/wgetpaste.conf, ~/.wgetpaste.conf etc.
        --version                 show version information

can be overridden globally in ""/etc/wgetpaste.conf or ""/etc/wgetpaste.d/*.conf or
per user in any of ~/.wgetpaste.conf or ~/.wgetpaste.d/*.conf.

An additional http header can be passed by setting HEADER_${SERVICE} in any of the
configuration files mentioned above. For example, authenticating with github gist:
HEADER_gists="Authorization: token 1234abc56789...", or with gitlab snippets:
HEADER_snippets="PRIVATE-TOKEN: 1234abc56789..."

You can also set PUBLIC_gists='false' if you want to default to secret instead of
public github gists. In the case of gitlab, you can set VISIBILITY_snippets= to
'public', 'private' or 'internal'"

To change your gitlab server, you can override the default API URL setting

Service selection

Before posting a snippet, care should be taken to select the desired service to post to.

To show which is the current default service, and list available services, use the --list-services (-S for short) option:

user $wgetpaste --list-services
Services supported: (case sensitive):
   Name:     | Url:
    0x0      | http://0x0.st
    bpaste   | https://bpa.st/api/v1/paste
    codepad  | http://codepad.org/
    dpaste   | http://dpaste.com/api/v2/
    gists    | https://api.github.com/gists
    ix_io    | http://ix.io
    snippets | https://gitlab.com/api/v4/snippets
   *pgz      | https://paste.gentoo.zip

The default service is marked with an asterisk, this service will be used unless a different service is selected with the --service (-s for short) option, when pasting. For example:

user $wgetpaste --service codepad file.txt

Different paste services have different constraints, such as allowable size, retention period etc. Go to the service website for full information. For larger posts, 0x0 may be useful.

It may be preferable to simply set a sensible default service before use, or just leave it as "dpaste" - see the configuration section.

Posting a file

To post a file, simply run wgetpaste followed by the filename, not forgetting to specify a paste service if somthing other than the default is required.

For example, run the following command to create a paste of the system's Xorg configuration:

user $wgetpaste /etc/X11/xorg.conf

To create a paste of xorg.conf using the tiny URL service use the --tinyurl option (-u for short):

user $wgetpaste --tinyurl /etc/X11/xorg.conf

Post command output

A command's output may be directly posted to a snippet service, though it is recommended to write output to a file and check the contents before pasting, to avoid any possible security issues.

To paste the entire output of a command, use the --command (-c for short) option. Remember to quote the command:

user $wgetpaste --command 'emerge -vp musique'

Output can also be piped to wgetpaste, but this will only include stdout by default. Use |& to include stderr as well:

user ${ echo "Hello, stdout!"; echo "Hello, stderr!" >&2; } |& wgetpaste

Advanced options

To set a language for syntax highlighting use the --language (-l for short) option:

user $wgetpaste --language Bash /etc/bash/bashrc

Use the --list-languages (-L for short) option to list all available languages, these depend on the selected paste service:

user $wgetpaste --list-languages
See the invocation section for other advanced options, such as automatically adding system diagnostic information, or pasting to or from clipboards.

Removing ANSI sequences with ansifilter

wgetpaste 2.33 and newer supports --no-ansi (-N) to automatically filter via ansifilter. It also supports NOANSI=1 in .wgetpaste.conf.

For getting color on terminals, ANSI sequences are used. When uploading a logfile these can be annoying (in particular it makes it hard to search for error messages), e.g.:

�[32m * �[39;49;00mPackage:    x11-wm/dwm-6.2
�[32m * �[39;49;00mRepository: gentoo
�[32m * �[39;49;00mMaintainer: gyakovlev@gentoo.org
�[32m * �[39;49;00mUSE:        abi_x86_64 amd64 elibc_glibc kernel_linux savedconfig userland_GNU xinerama
�[32m * �[39;49;00mFEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox

app-text/ansifilter removes these control characters. To install:

root #emerge --ask app-text/ansifilter

Filter the build.log and write it to /tmp:

user $ansifilter /var/tmp/portage/cat/package-1.23/temp/build.log > /tmp/build.log

Upload /tmp/build.log with wgetpaste:

user $wgetpaste /tmp/build.log

External resources

See also

  • Support — provide support for technical issues encountered when installing or using Gentoo Linux
  • Troubleshooting — provide users with a set of techniques and tools to troubleshoot and fix problems with their Gentoo setups.