-
-
Save lirlia/dafb2e8d021f1156fc47693873f0d4b6 to your computer and use it in GitHub Desktop.
This file contains 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
function kurl() { | |
# URLをパース | |
read proto server path <<<$(echo ${1//// }) | |
DOC=/${path// //} | |
HOST=${server//:*} | |
PORT=${server//*:} | |
[[ x"${HOST}" == x"${PORT}" ]] && PORT=80 | |
# /dev/tcp/~をfd3で開く | |
exec 3<>/dev/tcp/${HOST}/$PORT | |
# HTTPリクエストを送る | |
echo -en "GET ${DOC} HTTP/1.0\r\nHost: ${HOST}\r\n\r\n" >&3 | |
# レスポンスを読み取る | |
(while read line; do | |
[[ "$line" == $'\r' ]] && break | |
done && cat) <&3 | |
# #3 fdをクローズする | |
exec 3>&- | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script is download file from HTTP.
You can use this command like
kurl http://mysite:8000/myscript.sh
.This script isn't adopt HTTPS.