Hi I was hoping some one would know if it is possible to url encode a string using sed?
My problem is I have extracted some key value pairs from a text file with sed, and will be inserting these pairs as source variables into a curl script to automatically download some xml from our server.
My problem is that one of the value pairs needs to be url encoded. The "j_password=0NRx5KpiquE32LrlXApzrA==" needs to be url encoded
Below are my key value pairs
JSESSIONID0=1omyjon28ge2p8dnuo0ngrjps
j_password=0NRx5KpiquE32LrlXApzrA==
iv=e10d17fd73b1f684986ecc3afbe68ff3
salt=90c6ea71b949661dcfb4b6ccaf51ecc6
_uc=MDSz8K74i642sedqmp88Jg==
_ut=1518796880482
JSESSIONID=1ozzynzzoqu8o1sgbqhuoek5hy
SSO_ID=5ohshkk9is9eb
workstationId=nfFqyQ0vDc2Bs5IQdhZNQg==
These pairs will be read into a curl script, Below is part of the line from my curl script that the key value pairs will be read in as variables;
curl 'http://192.168.1.55/epace/do-login' lastLoggedInCompany=public;~~ JSESSIONID=$JSESSIONID0' -H 'Origin: http://192.168.1.55' -H~~'Referer: http://192.168.1.55/epace/login.html' -H 'Connection: keep-alive' --data 'j_username=ticorder&j_password=$j_password&lastLoggedInCompany=public&iv=$iv&salt=$salt&hash=' --compressed
I had read online that curl can be used to url encode. Although I am not sure how I would use this function in curl to encode only part of the curl command that I need url encoded?
The script I am using to extract the value pairs is below
sed -i ' -e ' -n '/POST/,$p' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e $'s/\t/\ /g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e $'s/\ \ /\ /g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e $'s/\ GET.*//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e $'s/.*_uc\=/_uc\=/g' /WebLoads/MainGo/CaptureFile-0
sed -i ' -e ' -n '/.*/,// G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e $'s/\t/\ /g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/.*\=public\;\ JSESSIONID\=/JSESSIONID0\=/g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/Form item\:\ /\'$'\n/g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/\ POST.*//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/.*j_username.*//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/.*companySelection.*//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/.*Login.*//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/.*lastLoggedInCompany.*//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/.*hash.*//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/\;\ /\'$'\n/g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/\"\ =\ \"/\=/g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/\"\,//g' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e s'/^\"//g' /WebLoads/MainGo/CaptureFile-0
sed -i ' -e ' -n '/.*/,// G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' /WebLoads/MainGo/CaptureFile-0
sed -i '' -e '/^\s*$/d' /WebLoads/MainGo/CaptureFile-0
I've looked online and it does not seem very hopeful to be able to accomplish this with sed, but It would be my first choice since my understanding of sed is better than some of the other available programs. If there is another way of accomplishing this with another program I would be more than thankful if some one was able to show me how this could be done.
Thank you
Paul