Last active
August 8, 2019 05:28
-
-
Save composite/e3579db71ea6da9485745a1fbe7301d6 to your computer and use it in GitHub Desktop.
file content as post parameter value example (split by backslash for getting multiple request)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| function post() { | |
| mkdir -p "$HOME/tmp/" | |
| local a="$HOME/tmp/Q_$(openssl rand -hex 16).req" | |
| echo > "$a" | |
| vi "$a" | |
| local b="" | |
| local c="" | |
| local t="" | |
| local n=$(printf '\n') | |
| local e=$(printf '\\') | |
| local x="\\\\+" | |
| while read -r r; do | |
| t=$(echo "$r" | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') | |
| [ -z "$t" ] && continue | |
| if [[ "$t" =~ $x && ! -z "$c" ]]; then | |
| b=$(echo "$c" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"+"') | |
| c="" | |
| wget -q -O- --post-data="data=$b" "http://localhost:8080/post/data" | |
| elif [ ! -z "$t" ]; then | |
| c="$c $t$n" | |
| fi | |
| done < "$a" | |
| if [ ! -z "$c" ]; then | |
| b=$(echo "$c" | perl -MURI::Escape -ne 'chomp;print uri_escape($_),"+"') | |
| wget -q -O- --post-data="data=$b" "http://localhost:8080/post/data" | |
| fi | |
| rm -f "$a" | |
| return 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment