If you're ever in the situation where you have access to a shell and need to download/install something, but don't have curl, wget, netcat or even telnet, find a handy bash script that lets you download a file from an HTTP source as a reply to this post.

It even fits in a single toot 😂

function __fakecurl() {
read proto server path <<<$(echo ${1//// })
DOC=/${path// //}
HOST=${server//:*}
PORT=${server//*:}
[[ x"${HOST}" == x"${PORT}" ]] && PORT=80

exec 3<>/dev/tcp/${HOST}/$PORT
echo -en "GET ${DOC} HTTP/1.1\r\nHost: ${HOST}\r\n\r\n" >&3
(while read line; do
[[ "$line" == $'\r' ]] && break
done && cat) <&3
exec 3>&-
}

Follow

@fribbledom Unix: “Do one thing well.”

Bash: “No.”

Sign in to participate in the conversation
pdx.social

pdx.social is a server for folks who live in the Portland, OR region. Registration is by invitation only and you can receive an invitation by contacting a member or emailing admin@pdx.social. You must abide by our Code of Conduct.

Hosted at masto.host. Donations gratefully accepted via LiberaPay