TEXT 40
Upload to pastebin from command line Guest on 7th July 2020 10:28:54 AM
  1. text sharing services available to upload and share text snippets, error logs, config files, a command’s output or any sort of text files. If you happen to share your code often using various Pastebin-like services, I do have a good news for you. Say hello to Wgetpaste, a command line BASH utility to easily upload text snippets to pastebin-like services. Using Wgetpaste script, anyone can quickly share text snippets to their friends, colleagues, or whoever wants to see/use/review the code from command line in Unix-like systems.
  2.  
  3. Installing Wgetpaste
  4. Wgetpaste is available in Arch Linux [Community] repository. To install it on Arch Linux and its variants like Antergos and Manjaro Linux, just run the following command:
  5.  
  6. $ sudo pacman -S wgetpaste
  7. For other distributions, grab the source code from Wgetpaste website and install it manually as described below.
  8.  
  9. First download the latest Wgetpaste tar file:
  10.  
  11. $ wget http://wgetpaste.zlin.dk/wgetpaste-2.28.tar.bz2
  12. Extract it:
  13.  
  14. $ tar -xvjf wgetpaste-2.28.tar.bz2
  15. It will extract the contents of the tar file in a folder named “wgetpaste-2.28”.
  16.  
  17. Go to that directory:
  18.  
  19. $ cd wgetpaste-2.28/
  20. Copy the wgetpaste binary to your $PATH, for example /usr/local/bin/.
  21.  
  22. $ sudo cp wgetpaste /usr/local/bin/
  23. Finally, make it executable using command:
  24.  
  25. $ sudo chmod +x /usr/local/bin/wgetpaste
  26. Upload Text Snippets To Pastebin-like Services
  27. Uploading text snippets using Wgetpaste is trivial. Let me show you a few examples.
  28.  
  29. 1. Upload text files
  30. To upload any text file using Wgetpaste, just run:
  31.  
  32. $ wgetpaste mytext.txt
  33. This command will upload the contents of mytext.txt file.
  34.  
  35. Sample output:
  36.  
  37. Your paste can be seen here: https://paste.pound-python.org/show/eO0aQjTgExP0wT5uWyX7/
  38. wgetpaste 1
  39. Upload text snippets to pastebin services
  40.  
  41. You can share the pastebin URL via any medium like mail, message, whatsapp or IRC etc. Whoever has this URL can visit it and view the contents of the text file in a web browser of their choice.
  42.  
  43. Here is the contents of mytext.txt file in web browser:
  44.  
  45. wgetpaste 2
  46. Viewing pastebin contents via browser
  47.  
  48. You can also use ‘tee’ command to display what is being pasted, instead of uploading them blindly.
  49.  
  50. To do so, use -t option like below.
  51.  
  52. $ wgetpaste -t mytext.txt
  53.  
  54.  
  55. 2. Upload text snippets to different services
  56. By default, Wgetpaste will upload the text snippets to poundpython service.
  57.  
  58. To view the list of supported services, run:
  59.  
  60. $ wgetpaste -S
  61. Sample output:
  62.  
  63. Services supported: (case sensitive):
  64. Name:              | Url:
  65. =============|=================
  66. bpaste             | https://bpaste.net/
  67. codepad           | http://codepad.org/
  68. dpaste             | http://dpaste.com/
  69. gists                | https://api.github.com/gists
  70. *poundpython   | https://paste.pound-python.org/
  71. Here, * indicates the default service.
  72.  
  73. As you can see, Wgetpaste currently supports five text sharing services. I didn’t try all of them, but I believe all services will work.
  74.  
  75. To upload the contents to other services, for example bpaste.net, use -s option like below.
  76.  
  77.  
  78.  
  79. $ wgetpaste -s bpaste mytext.txt
  80. Your paste can be seen here: https://bpaste.net/show/5199e127e733
  81. 3. Read input from stdin
  82. Wgetpaste can also read the input from stdin.
  83.  
  84. $ uname -a | wgetpaste
  85. This command will upload the output of ‘uname -a’ command.
  86.  
  87. 4. Upload the COMMAND and the output of COMMAND together
  88. Sometimes, you may need to paste a COMMAND and its output. To do so, specify the contents of the command within quotes like below.
  89.  
  90. $ wgetpaste -c 'ls -l'
  91. This will upload the command ‘ls -l’ along with its output to the pastebin service.
  92.  
  93. This can be useful when you wanted to let others to clearly know what was the exact command you just ran and its output.
  94.  
  95.  
  96.  
  97. As you can see in the output, I ran ‘ls -l’ command.
  98.  
  99. 5. Upload system log files, config files
  100. Like I already said, we can upload any sort of text files, not just an ordinary text file, in your system such as log files, a specific command’s output etc. Say for example, you just updated your Arch Linux box and ended up with a broken system. You ask your colleague how to fix it and s/he wants to read the pacman.log file. Here is the command to upload the contents of the pacman.log file:
  101.  
  102. $ wgetpaste /var/log/pacman.log
  103. Share the pastebin URL with your Colleague, so s/he will review the pacman.log and may help you to fix the problem by reviewing the log file.
  104.  
  105. Usually, the contents of log files might be too long and you don’t want to share them all. In such cases, just use cat command to read the output and use tail command with the -n switch to define the number of lines to share and finally pipe the output to Wgetpaste as shown below.
  106.  
  107. $ cat /var/log/pacman.log | tail -n 50 | wgetpaste
  108. The above command will upload only the last 50 lines of pacman.log file.
  109.  
  110. 6. Convert input url to tinyurl
  111. By default, Wgetpaste will display the full pastebin URL in the output. If you want to convert the input URL to a tinyurl, just use -u option.
  112.  
  113. $ wgetpaste -u mytext.txt
  114. Your paste can be seen here: http://tinyurl.com/y85d8gtz
  115. 7. Set language
  116. By default, Wgetpaste will upload text snippets in plain text.
  117.  
  118. To list languages supported by the specified service, use -L option.
  119.  
  120. $ wgetpaste -L
  121. This command will list all languages supported by default service i.e poundpython (https://paste.pound-python.org/).
  122.  
  123. We can change this using -l option.
  124.  
  125. $ wgetpaste -l Bash mytext.txt
  126. 8. Disable syntax highlighting or html in the output
  127. As I mentioned above, the text snippets will be displayed in a specific language format (plaintext, Bash etc.).
  128.  
  129. You can, however, change this behaviour to display the raw text snippets using -r option.
  130.  
  131.  
  132.  
  133. $ wgetpaste -r mytext.txt
  134. Your raw paste can be seen here: https://paste.pound-python.org/raw/CUJhQ3jEmr2UvfmD2xCL/
  135.  
  136. Upload and display raw output
  137.  
  138. As you can see in the above output, there is no syntax highlighting, no html formatting. Just a raw output.
  139.  
  140. 9. Change Wgetpaste defaults
  141. All Defaults values (DEFAULT_{NICK,LANGUAGE,EXPIRATION}[_${SERVICE}] and DEFAULT_SERVICE)
  142. can be changed globally in /etc/wgetpaste.conf or per user in ~/.wgetpaste.conf files. These files, however, are not available by default in my system. I guess we need to manually create them. The developer has given the sample contents for both files here and here. Just create these files manually with given sample contents and modify the parameters accordingly to change Wgetpaste defaults.
  143.  
  144. 10. Getting help
  145. To display the help section, run:
  146.  
  147. $ wgetpaste -h

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.