Advertisement
GuessGen

Broke_this(8)

Jan 17th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.35 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. function RemoveExtraSpaces(){
  4.     echo $1
  5. }
  6.  
  7. function FindAndReplace(){
  8.      echo ${1//$2/$3}
  9. }
  10.  
  11. function HtmlEncode(){
  12.     echo "$1" | recode ascii..html
  13. }
  14.  
  15. function HtmlDecode(){
  16.     echo "$1" | xmlstarlet unesc
  17. }
  18.  
  19. function ParseUrl(){
  20.     local http=80
  21.     local https=443
  22.     local ftp=21
  23.     echo "$1"
  24.     echo "HOST:" $3
  25.     echo -n "PORT: "
  26.     if [ ! $5 ]
  27.     then
  28.         if [ -v $5 ]
  29.         then
  30.             eval port='${'$2'}'
  31.             echo $port 
  32.         else
  33.             echo "Protocolul este gresit!"
  34.         fi
  35.     else
  36.         echo $5
  37.     fi
  38.     echo "DOC:" $4
  39.    
  40. }
  41.  
  42. echo "Introduceti stringul care doriti sa fie prelucrat"
  43. read str
  44. str=$(RemoveExtraSpaces "$str")
  45. echo "Spatiile in plus au fost eliminate!"
  46. echo $str
  47. printf "Cuvintul care dorinti sa-l inlocuiti: "
  48. read search
  49. printf "Cuvintul inlocuitor: "
  50. read replace
  51. str=$(FindAndReplace "$str" "$search" "$replace")
  52. echo "Stringul prelucrat: "
  53. echo $str
  54. str=$(HtmlEncode "$str")
  55. echo "Stringul cu simboluri codificate in HTML: "
  56. echo $str
  57. str=$(HtmlDecode "$str")
  58. echo "Stringul decodificat inapoi in ASCII: "
  59. echo $str
  60.  
  61. printf "Introduceti linkul: "
  62. read link
  63. printf "Introduceti protocolul: "
  64. read protocol
  65. printf "Introduceti hostul: "
  66. read host
  67. printf "Introduceti locatia documentului in host: "
  68. read doc
  69. printf "Introduceti portul (optional): "
  70. read port
  71. clear
  72. ParseUrl $link $protocol $host $doc $port > protocol.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement