Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- function RemoveExtraSpaces(){
- echo $1
- }
- function FindAndReplace(){
- echo ${1//$2/$3}
- }
- function HtmlEncode(){
- echo "$1" | recode ascii..html
- }
- function HtmlDecode(){
- echo "$1" | xmlstarlet unesc
- }
- function ParseUrl(){
- local http=80
- local https=443
- local ftp=21
- echo "$1"
- echo "HOST:" $3
- echo -n "PORT: "
- if [ ! $5 ]
- then
- if [ -v $5 ]
- then
- eval port='${'$2'}'
- echo $port
- else
- echo "Protocolul este gresit!"
- fi
- else
- echo $5
- fi
- echo "DOC:" $4
- }
- echo "Introduceti stringul care doriti sa fie prelucrat"
- read str
- str=$(RemoveExtraSpaces "$str")
- echo "Spatiile in plus au fost eliminate!"
- echo $str
- printf "Cuvintul care dorinti sa-l inlocuiti: "
- read search
- printf "Cuvintul inlocuitor: "
- read replace
- str=$(FindAndReplace "$str" "$search" "$replace")
- echo "Stringul prelucrat: "
- echo $str
- str=$(HtmlEncode "$str")
- echo "Stringul cu simboluri codificate in HTML: "
- echo $str
- str=$(HtmlDecode "$str")
- echo "Stringul decodificat inapoi in ASCII: "
- echo $str
- printf "Introduceti linkul: "
- read link
- printf "Introduceti protocolul: "
- read protocol
- printf "Introduceti hostul: "
- read host
- printf "Introduceti locatia documentului in host: "
- read doc
- printf "Introduceti portul (optional): "
- read port
- clear
- ParseUrl $link $protocol $host $doc $port > protocol.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement