Tools to interface with Teknik Services.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/usr/bin/env bash
  2. # name: teknik-paste
  3. # author: KittyKatt
  4. # requires: bash 4.0+, curl
  5. usage() {
  6. echo "\
  7. Teknik Pastebin Script in BASH \
  8. Usage : $(basename ${0}) [ -t <paste title> ] [ -e <paste expiration> ] [ -f <type of code> ] [ -p <password> ] [ -F <file> ] [ -h ]
  9. <paste title> Specify the title of paste to be used. (optional)
  10. <paste expiration> Specify expiration of paste. Either 1 day (1d) or 1 month (1m). Default is never. (optional)
  11. <type of code> Specify code language used, use any of the following values. (optional and default value is plain text)
  12. <password> Specify a password to protect your paste. (optional)
  13. => Some famous [ -f <type of code> ] Values::
  14. php - PHP
  15. actionscript3 - Action Script 3
  16. asp - ASP
  17. bash - BASH script
  18. c - C language
  19. csharp - C#
  20. cpp - C++"
  21. }
  22. querystring="paste=yes"
  23. while getopts "t:f:F:e:p:h" flags; do
  24. case "${flags}" in
  25. h)
  26. usage
  27. exit 0
  28. ;;
  29. t)
  30. title=$(echo "${OPTARG}" | tr ' ' '%20')
  31. querystring="${querystring}&title=${title}"
  32. ;;
  33. e)
  34. if [[ "${OPTARG}" == "1d" ]]; then
  35. expiry="d"
  36. elif [[ "${OPTARG}" == "1m" ]]; then
  37. expiry="m"
  38. else
  39. printf "That is not a valid expiration time. Specify either 1 day (1d) or 1 month (1m)."
  40. exit 1
  41. fi
  42. querystring="${querystring}&expiry=${expiry}"
  43. ;;
  44. F)
  45. if [ -z "${OPTARG}" ]; then
  46. printf 'You have to supply a file to upload to the pastebin!\n'
  47. exit 1
  48. else
  49. fileinput="${OPTARG}"
  50. fi
  51. ;;
  52. f)
  53. format="${OPTARG}"
  54. querystring="${querystring}&syntax=${format}"
  55. ;;
  56. p)
  57. password="${OPTARG}"
  58. querystring="${querystring}&password=${password}"
  59. ;;
  60. esac
  61. done
  62. if [ -n "${fileinput}" ]; then
  63. input=$(cat "${fileinput}")
  64. else
  65. input="$(</dev/stdin)"
  66. fi
  67. if [[ -n "${input}" ]]; then
  68. output=$(curl --silent --data "${querystring}" --data-urlencode "code=${input}" https://api.teknik.io/v1/Paste)
  69. pasteid=$(grep -Eo '"id":"[0-9a-zA-Z]+' <<< "${output}" | sed 's/\\//g')
  70. pasteid="${pasteid##\"id\":\"}"
  71. if [[ -n "${pasteid}" ]]; then
  72. [[ -n "${title}" ]] && printf "Title Specified: ${title}\n"
  73. [[ -n "${expiry}" ]] && printf "Expiration Specified: ${expiry}\n"
  74. [[ -n "${format}" ]] && printf "Paste Format Specified: ${format}\n"
  75. [[ -n "${password}" ]] && printf "Paste is password protected!\n"
  76. printf "Your paste can be found at https://paste.teknik.io/${pasteid}\n"
  77. exit 0
  78. else
  79. printf "There was an error submitting your paste! We are sorry."
  80. exit 1
  81. fi
  82. else
  83. printf "Error! Nothing found on standard input. Did you submit anything to paste?"
  84. exit 1
  85. fi